Download files code refractoring

This commit is contained in:
ClemDee
2019-08-14 14:49:40 +02:00
parent 4b027e83ad
commit bb9898fa35
6 changed files with 168 additions and 342 deletions

View File

@@ -3472,32 +3472,20 @@ define([
var downloadFolder = function (folderElement, folderName) {
console.warn("downloadFolder");
var todo = function (data) {
var getPad = function (data, cb) {
sframeChan.query("Q_CRYPTGET", data, function (err, obj) {
if (err) { return void cb(err); }
if (obj.error) { return void cb(obj.error); }
cb(null, obj.data);
}, { timeout: 60000 });
};
data.folder = folderElement;
folderName = Util.fixFileName(folderName) + '.zip';
console.log("data", data);
console.log("folderName", folderName);
Backup.create(data, getPad, function (blob, errors) {
Backup.create(data, common.getPad, function (blob, errors) {
console.log("blob", blob);
window.saveAs(blob, folderName);
console.error(errors);
}, function () {});
};
sframeChan.query("Q_SETTINGS_DRIVE_GET", "full", function (err, data) {
console.warn("sframeChan.query Q_SETTINGS_DRIVE_GET callback");
console.log("err", err);
console.log("data", data);
if (err) { return void console.error(err); }
if (data.error) { return void console.error(data.error); }
todo(data);
todo({
uo: proxy,
sf: folders,
});
};
@@ -3594,10 +3582,8 @@ define([
if (paths.length !== 1) { return; }
var path = paths[0];
el = manager.find(path.path);
console.log("paths", paths);
console.log("el", el);
console.log('path', path);
console.log("APP", APP);
// folder
if (manager.isFolder(el)) {
// folder
@@ -3625,7 +3611,6 @@ define([
else if (manager.isFile(el)) {
// imported file
if (path.element.is(".cp-border-color-file")) {
console.log("--isFile--");
data = manager.getFileData(el);
APP.FM.downloadFile(data, function (err, obj) {
console.log(err, obj);
@@ -3634,9 +3619,7 @@ define([
}
// pad
else {
console.log("--isPad--");
data = manager.getFileData(el);
console.log("data:", data);
APP.FM.downloadPad(data, function (err, obj) {
console.log(err, obj);
console.log('DONE');