Export folder is now working in drive

pull/1/head
ClemDee 5 years ago
parent 51241bda48
commit a0d85c6e34

@ -282,11 +282,12 @@ define([
max: 0, max: 0,
done: 0 done: 0
}; };
var filesData = data.sharedFolderId && ctx.sf[data.sharedFolderId] ? ctx.sf[data.sharedFolderId].filesData : ctx.data.filesData;
progress('reading', -1); progress('reading', -1);
nThen(function (waitFor) { nThen(function (waitFor) {
ctx.waitFor = waitFor; ctx.waitFor = waitFor;
var zipRoot = ctx.zip.folder('Root'); var zipRoot = ctx.zip.folder('Root');
makeFolder(ctx, ctx.folder, zipRoot, ctx.data.filesData); makeFolder(ctx, ctx.folder, zipRoot, filesData);
progress('download', {}); progress('download', {});
}).nThen(function () { }).nThen(function () {
console.log(ctx.zip); console.log(ctx.zip);
@ -308,11 +309,32 @@ define([
}; };
var _downloadFolder = function (ctx, data, cb, updateProgress) {
create(data, ctx.get, function (blob, errors) {
console.error(errors); // TODO show user errors
var dl = function () {
saveAs(blob, data.folderName);
};
cb(null, {download: dl});
}, function (state, progress) {
if (state === "reading") {
updateProgress.folderProgress(0);
}
if (state === "download") {
if (typeof progress.current !== "number") { return; }
updateProgress.folderProgress(progress.current / progress.max);
}
else if (state === "done") {
updateProgress.folderProgress(1);
}
});
};
return { return {
create: create, create: create,
downloadFile: _downloadFile, downloadFile: _downloadFile,
downloadPad: _downloadPad, downloadPad: _downloadPad,
downloadFolder: _downloadFolder,
}; };
}); });

@ -471,7 +471,7 @@ define([
width: progressValue * $pc.width() + 'px' width: progressValue * $pc.width() + 'px'
}); });
}; };
var updateProgress = function (progressValue) { var updateDecryptProgress = function (progressValue) {
var text = Math.round(progressValue*100) + '%'; var text = Math.round(progressValue*100) + '%';
text += progressValue === 1 ? '' : ' (' + Messages.download_step2 + '...)'; text += progressValue === 1 ? '' : ' (' + Messages.download_step2 + '...)';
$pv.text(text); $pv.text(text);
@ -479,12 +479,19 @@ define([
width: progressValue * $pc.width()+'px' width: progressValue * $pc.width()+'px'
}); });
}; };
var updateProgress = function (progressValue) {
var text = Math.round(progressValue*100) + '%';
$pv.text(text);
$pb.css({
width: progressValue * $pc.width()+'px'
});
};
var ctx = { var ctx = {
get: common.getPad, get: common.getPad,
sframeChan: sframeChan, sframeChan: sframeChan,
}; };
var dl = downloadFunction(ctx, data, function (err, obj) { downloadFunction(ctx, data, function (err, obj) {
$link.prepend($('<span>', {'class': 'fa fa-external-link'})) $link.prepend($('<span>', {'class': 'fa fa-external-link'}))
.attr('href', '#') .attr('href', '#')
.click(function (e) { .click(function (e) {
@ -496,16 +503,18 @@ define([
cb(err, obj); cb(err, obj);
}, { }, {
progress: updateDLProgress, progress: updateDLProgress,
progress2: updateProgress, progress2: updateDecryptProgress,
folderProgress: updateProgress,
}); });
var $cancel = $('<span>', {'class': 'cp-fileupload-table-cancel-button fa fa-times'}).click(function () { // var $cancel = $('<span>', {'class': 'cp-fileupload-table-cancel-button fa fa-times'}).click(function () {
dl.cancel(); // dl.cancel();
$cancel.remove(); // $cancel.remove();
$row.find('.cp-fileupload-table-progress-value').text(Messages.upload_cancelled); // $row.find('.cp-fileupload-table-progress-value').text(Messages.upload_cancelled);
done(); // done();
}); // });
$row.find('.cp-fileupload-table-cancel').html('').append($cancel); // $row.find('.cp-fileupload-table-cancel').html('').append($cancel);
$row.find('.cp-fileupload-table-cancel').html('');
}; };
@ -528,6 +537,14 @@ define([
}); });
}; };
File.downloadFolder = function (data, cb) {
queue.push({
dl: function (file) { updateProgressbar(file, data, MakeBackup.downloadFolder, cb); },
size: 0,
name: data.folderName,
});
};
return File; return File;
}; };

@ -3597,19 +3597,16 @@ define([
}; };
var downloadFolder = function (folderElement, folderName) { var downloadFolder = function (folderElement, folderName, sfId) {
console.warn("downloadFolder");
var todo = function (data) { var todo = function (data) {
data.folder = folderElement; data.folder = folderElement;
folderName = Util.fixFileName(folderName) + '.zip'; data.sharedFolderId = sfId;
console.log("data", data); data.folderName = Util.fixFileName(folderName) + '.zip';
console.log("folderName", folderName);
APP.FM.downloadFolder(data, function (err, obj) {
Backup.create(data, common.getPad, function (blob, errors) { console.log(err, obj);
console.log("blob", blob); console.log('DONE');
window.saveAs(blob, folderName); });
console.error(errors);
}, function () {});
}; };
todo({ todo({
uo: proxy, uo: proxy,
@ -3711,29 +3708,21 @@ define([
if (paths.length !== 1) { return; } if (paths.length !== 1) { return; }
var path = paths[0]; var path = paths[0];
el = manager.find(path.path); el = manager.find(path.path);
console.log("el", el);
console.log('path', path);
// folder // folder
if (manager.isFolder(el)) { if (manager.isFolder(el)) {
// folder // folder
var name, folderEl; var name, folderEl;
if (!manager.isSharedFolder(el)) { if (!manager.isSharedFolder(el)) {
console.log("--isFolder--");
name = path.path[path.path.length - 1]; name = path.path[path.path.length - 1];
console.log('name', name);
folderEl = el; folderEl = el;
downloadFolder(folderEl, name); downloadFolder(folderEl, name);
} }
// shared folder // shared folder
else { else {
console.log("--isSharedFolder--");
data = manager.getSharedFolderData(el); data = manager.getSharedFolderData(el);
name = data.title; name = data.title;
folderEl = manager.find(path.path.concat("root")); folderEl = manager.find(path.path.concat("root"));
console.log("folderEl", folderEl); downloadFolder(folderEl, name, el);
console.log("data:", data);
console.log('name', name);
downloadFolder(folderEl, name);
} }
} }
// file // file

Loading…
Cancel
Save