|
|
@ -21,16 +21,22 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var transform = function (ctx, type, sjson, cb) {
|
|
|
|
var transform = function (ctx, type, sjson, cb) {
|
|
|
|
|
|
|
|
console.error("backup - transform");
|
|
|
|
|
|
|
|
console.log('type', type);
|
|
|
|
|
|
|
|
console.log('sjson', sjson);
|
|
|
|
|
|
|
|
|
|
|
|
var result = {
|
|
|
|
var result = {
|
|
|
|
data: sjson,
|
|
|
|
data: sjson,
|
|
|
|
ext: '.json',
|
|
|
|
ext: '.json',
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
console.log('result', result);
|
|
|
|
var json;
|
|
|
|
var json;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
json = JSON.parse(sjson);
|
|
|
|
json = JSON.parse(sjson);
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
return void cb(result);
|
|
|
|
return void cb(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('json', json);
|
|
|
|
var path = '/' + type + '/export.js';
|
|
|
|
var path = '/' + type + '/export.js';
|
|
|
|
require([path], function (Exporter) {
|
|
|
|
require([path], function (Exporter) {
|
|
|
|
Exporter.main(json, function (data) {
|
|
|
|
Exporter.main(json, function (data) {
|
|
|
@ -46,6 +52,8 @@ define([
|
|
|
|
// Add a file to the zip. We have to cryptget&transform it if it's a pad
|
|
|
|
// Add a file to the zip. We have to cryptget&transform it if it's a pad
|
|
|
|
// or fetch&decrypt it if it's a file.
|
|
|
|
// or fetch&decrypt it if it's a file.
|
|
|
|
var addFile = function (ctx, zip, fData, existingNames) {
|
|
|
|
var addFile = function (ctx, zip, fData, existingNames) {
|
|
|
|
|
|
|
|
console.error('backup - addFile');
|
|
|
|
|
|
|
|
console.log('fData', fData);
|
|
|
|
if (!fData.href && !fData.roHref) {
|
|
|
|
if (!fData.href && !fData.roHref) {
|
|
|
|
return void ctx.errors.push({
|
|
|
|
return void ctx.errors.push({
|
|
|
|
error: 'EINVAL',
|
|
|
|
error: 'EINVAL',
|
|
|
@ -54,6 +62,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var parsed = Hash.parsePadUrl(fData.href || fData.roHref);
|
|
|
|
var parsed = Hash.parsePadUrl(fData.href || fData.roHref);
|
|
|
|
|
|
|
|
console.log('parsed', parsed);
|
|
|
|
if (['pad', 'file'].indexOf(parsed.hashData.type) === -1) { return; }
|
|
|
|
if (['pad', 'file'].indexOf(parsed.hashData.type) === -1) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
// waitFor is used to make sure all the pads and files are process before downloading the zip.
|
|
|
|
// waitFor is used to make sure all the pads and files are process before downloading the zip.
|
|
|
@ -189,6 +198,7 @@ define([
|
|
|
|
var ctx = {
|
|
|
|
var ctx = {
|
|
|
|
get: getPad,
|
|
|
|
get: getPad,
|
|
|
|
data: data.uo.drive,
|
|
|
|
data: data.uo.drive,
|
|
|
|
|
|
|
|
folder: data.folder || ctx.data.root,
|
|
|
|
sf: data.sf,
|
|
|
|
sf: data.sf,
|
|
|
|
zip: new JsZip(),
|
|
|
|
zip: new JsZip(),
|
|
|
|
errors: [],
|
|
|
|
errors: [],
|
|
|
@ -201,7 +211,7 @@ define([
|
|
|
|
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.data.root, zipRoot, ctx.data.filesData);
|
|
|
|
makeFolder(ctx, ctx.folder, zipRoot, ctx.data.filesData);
|
|
|
|
progress('download', {});
|
|
|
|
progress('download', {});
|
|
|
|
}).nThen(function () {
|
|
|
|
}).nThen(function () {
|
|
|
|
console.log(ctx.zip);
|
|
|
|
console.log(ctx.zip);
|
|
|
|