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,
done: 0
};
var filesData = data.sharedFolderId && ctx.sf[data.sharedFolderId] ? ctx.sf[data.sharedFolderId].filesData : ctx.data.filesData;
progress('reading', -1);
nThen(function (waitFor) {
ctx.waitFor = waitFor;
var zipRoot = ctx.zip.folder('Root');
makeFolder(ctx, ctx.folder, zipRoot, ctx.data.filesData);
makeFolder(ctx, ctx.folder, zipRoot, filesData);
progress('download', {});
}).nThen(function () {
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 {
create: create,
downloadFile: _downloadFile,
downloadPad: _downloadPad,
downloadFolder: _downloadFolder,
};
});

@ -471,7 +471,7 @@ define([
width: progressValue * $pc.width() + 'px'
});
};
var updateProgress = function (progressValue) {
var updateDecryptProgress = function (progressValue) {
var text = Math.round(progressValue*100) + '%';
text += progressValue === 1 ? '' : ' (' + Messages.download_step2 + '...)';
$pv.text(text);
@ -479,12 +479,19 @@ define([
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 = {
get: common.getPad,
sframeChan: sframeChan,
};
var dl = downloadFunction(ctx, data, function (err, obj) {
downloadFunction(ctx, data, function (err, obj) {
$link.prepend($('<span>', {'class': 'fa fa-external-link'}))
.attr('href', '#')
.click(function (e) {
@ -496,16 +503,18 @@ define([
cb(err, obj);
}, {
progress: updateDLProgress,
progress2: updateProgress,
progress2: updateDecryptProgress,
folderProgress: updateProgress,
});
var $cancel = $('<span>', {'class': 'cp-fileupload-table-cancel-button fa fa-times'}).click(function () {
dl.cancel();
$cancel.remove();
$row.find('.cp-fileupload-table-progress-value').text(Messages.upload_cancelled);
done();
});
$row.find('.cp-fileupload-table-cancel').html('').append($cancel);
// var $cancel = $('<span>', {'class': 'cp-fileupload-table-cancel-button fa fa-times'}).click(function () {
// dl.cancel();
// $cancel.remove();
// $row.find('.cp-fileupload-table-progress-value').text(Messages.upload_cancelled);
// done();
// });
// $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;
};

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

Loading…
Cancel
Save