|
|
|
@ -109,24 +109,27 @@ define([
|
|
|
|
|
}]
|
|
|
|
|
};
|
|
|
|
|
var fo = FO.init(files, config);
|
|
|
|
|
fo.fixFiles();
|
|
|
|
|
if (files['CryptPad_RECENTPADS'] || !files.filesData) {
|
|
|
|
|
console.log("DRIVE1: migration from RECENTPADS to filesData failed");
|
|
|
|
|
return cb();
|
|
|
|
|
}
|
|
|
|
|
var fileKey = Object.keys(files.root.Folder2)[0];
|
|
|
|
|
if (!fileKey) { return cb(); }
|
|
|
|
|
var fileId = files.root.Folder2[fileKey];
|
|
|
|
|
var res = typeof fileId === "number"
|
|
|
|
|
&& typeof files.filesData[fileId] === "object"
|
|
|
|
|
&& files.filesData[fileId].filename === "FileName"
|
|
|
|
|
&& typeof files.trash.DeletedF[1].element === "number"
|
|
|
|
|
&& typeof files.filesData[files.trash.DeletedF[1].element] === "object"
|
|
|
|
|
&& files.filesData[files.trash.DeletedF[1].element].filename === "DeletedF"
|
|
|
|
|
&& typeof files.template[0] === "number"
|
|
|
|
|
&& typeof files.filesData[files.template[0]] === "object"
|
|
|
|
|
&& !files.filesData[files.template[0]].filename;
|
|
|
|
|
return cb(res);
|
|
|
|
|
var todo = function () {
|
|
|
|
|
fo.fixFiles();
|
|
|
|
|
if (files['CryptPad_RECENTPADS'] || !files.filesData) {
|
|
|
|
|
console.log("DRIVE1: migration from RECENTPADS to filesData failed");
|
|
|
|
|
return cb();
|
|
|
|
|
}
|
|
|
|
|
var fileKey = Object.keys(files.root.Folder2)[0];
|
|
|
|
|
if (!fileKey) { return cb(); }
|
|
|
|
|
var fileId = files.root.Folder2[fileKey];
|
|
|
|
|
var res = typeof fileId === "number"
|
|
|
|
|
&& typeof files.filesData[fileId] === "object"
|
|
|
|
|
&& files.filesData[fileId].filename === "FileName"
|
|
|
|
|
&& typeof files.trash.DeletedF[1].element === "number"
|
|
|
|
|
&& typeof files.filesData[files.trash.DeletedF[1].element] === "object"
|
|
|
|
|
&& files.filesData[files.trash.DeletedF[1].element].filename === "DeletedF"
|
|
|
|
|
&& typeof files.template[0] === "number"
|
|
|
|
|
&& typeof files.filesData[files.template[0]] === "object"
|
|
|
|
|
&& !files.filesData[files.template[0]].filename;
|
|
|
|
|
return cb(res);
|
|
|
|
|
};
|
|
|
|
|
fo.migrate(todo);
|
|
|
|
|
}, "DRIVE1: migration and fixFiles without unsorted");
|
|
|
|
|
|
|
|
|
|
assert(function (cb) {
|
|
|
|
@ -153,33 +156,36 @@ define([
|
|
|
|
|
}]
|
|
|
|
|
};
|
|
|
|
|
var fo = FO.init(files, config);
|
|
|
|
|
fo.fixFiles();
|
|
|
|
|
if (files['CryptPad_RECENTPADS'] || !files.filesData) {
|
|
|
|
|
console.log("DRIVE2: migration from RECENTPADS to filesData failed");
|
|
|
|
|
return cb();
|
|
|
|
|
}
|
|
|
|
|
if (!files.template) {
|
|
|
|
|
console.log("DRIVE2: template is missing");
|
|
|
|
|
return cb();
|
|
|
|
|
}
|
|
|
|
|
if (files.unsorted) {
|
|
|
|
|
console.log("DRIVE2: unsorted not removed");
|
|
|
|
|
return cb();
|
|
|
|
|
}
|
|
|
|
|
var fileKey = Object.keys(files.root.Folder2)[0];
|
|
|
|
|
var fileKey2 = Object.keys(files.root).filter(function (x) {
|
|
|
|
|
return typeof files.root[x] === "number";
|
|
|
|
|
})[0];
|
|
|
|
|
if (!fileKey || !fileKey2) { return cb(); }
|
|
|
|
|
var fileId = files.root.Folder2[fileKey];
|
|
|
|
|
var fileId2 = files.root[fileKey2];
|
|
|
|
|
var res = typeof fileId === "number"
|
|
|
|
|
&& typeof files.filesData[fileId] === "object"
|
|
|
|
|
&& files.filesData[fileId].filename === "FileName"
|
|
|
|
|
&& typeof fileId2 === "number"
|
|
|
|
|
&& typeof files.filesData[fileId2] === "object"
|
|
|
|
|
&& !files.filesData[fileId2].filename;
|
|
|
|
|
return cb(res);
|
|
|
|
|
var todo = function () {
|
|
|
|
|
fo.fixFiles();
|
|
|
|
|
if (files['CryptPad_RECENTPADS'] || !files.filesData) {
|
|
|
|
|
console.log("DRIVE2: migration from RECENTPADS to filesData failed");
|
|
|
|
|
return cb();
|
|
|
|
|
}
|
|
|
|
|
if (!files.template) {
|
|
|
|
|
console.log("DRIVE2: template is missing");
|
|
|
|
|
return cb();
|
|
|
|
|
}
|
|
|
|
|
if (files.unsorted) {
|
|
|
|
|
console.log("DRIVE2: unsorted not removed");
|
|
|
|
|
return cb();
|
|
|
|
|
}
|
|
|
|
|
var fileKey = Object.keys(files.root.Folder2)[0];
|
|
|
|
|
var fileKey2 = Object.keys(files.root).filter(function (x) {
|
|
|
|
|
return typeof files.root[x] === "number";
|
|
|
|
|
})[0];
|
|
|
|
|
if (!fileKey || !fileKey2) { return cb(); }
|
|
|
|
|
var fileId = files.root.Folder2[fileKey];
|
|
|
|
|
var fileId2 = files.root[fileKey2];
|
|
|
|
|
var res = typeof fileId === "number"
|
|
|
|
|
&& typeof files.filesData[fileId] === "object"
|
|
|
|
|
&& files.filesData[fileId].filename === "FileName"
|
|
|
|
|
&& typeof fileId2 === "number"
|
|
|
|
|
&& typeof files.filesData[fileId2] === "object"
|
|
|
|
|
&& !files.filesData[fileId2].filename;
|
|
|
|
|
return cb(res);
|
|
|
|
|
};
|
|
|
|
|
fo.migrate(todo);
|
|
|
|
|
}, "DRIVE2: migration and fixFiles with unsorted");
|
|
|
|
|
|
|
|
|
|
assert(function (cb) {
|
|
|
|
@ -204,33 +210,36 @@ define([
|
|
|
|
|
"CryptPad_RECENTPADS": []
|
|
|
|
|
};
|
|
|
|
|
var fo = FO.init(files, config);
|
|
|
|
|
fo.fixFiles();
|
|
|
|
|
if (files['CryptPad_RECENTPADS'] || !files.filesData) {
|
|
|
|
|
console.log("DRIVE2: migration from RECENTPADS to filesData failed");
|
|
|
|
|
return cb();
|
|
|
|
|
}
|
|
|
|
|
var fileKey = Object.keys(files.root.Folder2)[0];
|
|
|
|
|
var fileKey2 = Object.keys(files.trash.DeletedF[0].element)[0];
|
|
|
|
|
if (!fileKey || !fileKey2) { return cb(); }
|
|
|
|
|
var fileId = files.root.Folder2[fileKey];
|
|
|
|
|
var fileId2 = files.trash.DeletedF[0].element[fileKey2];
|
|
|
|
|
var res = typeof fileId === "number"
|
|
|
|
|
&& typeof files.filesData[fileId] === "object"
|
|
|
|
|
&& files.filesData[fileId].filename === "FileName"
|
|
|
|
|
&& files.filesData[fileId].href === href1
|
|
|
|
|
&& typeof files.trash.DeletedF[1].element === "number"
|
|
|
|
|
&& typeof files.filesData[files.trash.DeletedF[1].element] === "object"
|
|
|
|
|
&& files.filesData[files.trash.DeletedF[1].element].filename === "DeletedF"
|
|
|
|
|
&& files.filesData[files.trash.DeletedF[1].element].href === href2
|
|
|
|
|
&& typeof files.template[0] === "number"
|
|
|
|
|
&& typeof files.filesData[files.template[0]] === "object"
|
|
|
|
|
&& !files.filesData[files.template[0]].filename
|
|
|
|
|
&& files.filesData[files.template[0]].href === href3
|
|
|
|
|
&& typeof fileId2 === "number"
|
|
|
|
|
&& typeof files.filesData[fileId2] === "object"
|
|
|
|
|
&& files.filesData[fileId2].filename === "Trash"
|
|
|
|
|
&& files.filesData[fileId2].href === href4;
|
|
|
|
|
return cb(res);
|
|
|
|
|
var todo = function () {
|
|
|
|
|
fo.fixFiles();
|
|
|
|
|
if (files['CryptPad_RECENTPADS'] || !files.filesData) {
|
|
|
|
|
console.log("DRIVE2: migration from RECENTPADS to filesData failed");
|
|
|
|
|
return cb();
|
|
|
|
|
}
|
|
|
|
|
var fileKey = Object.keys(files.root.Folder2)[0];
|
|
|
|
|
var fileKey2 = Object.keys(files.trash.DeletedF[0].element)[0];
|
|
|
|
|
if (!fileKey || !fileKey2) { return cb(); }
|
|
|
|
|
var fileId = files.root.Folder2[fileKey];
|
|
|
|
|
var fileId2 = files.trash.DeletedF[0].element[fileKey2];
|
|
|
|
|
var res = typeof fileId === "number"
|
|
|
|
|
&& typeof files.filesData[fileId] === "object"
|
|
|
|
|
&& files.filesData[fileId].filename === "FileName"
|
|
|
|
|
&& files.filesData[fileId].href === href1
|
|
|
|
|
&& typeof files.trash.DeletedF[1].element === "number"
|
|
|
|
|
&& typeof files.filesData[files.trash.DeletedF[1].element] === "object"
|
|
|
|
|
&& files.filesData[files.trash.DeletedF[1].element].filename === "DeletedF"
|
|
|
|
|
&& files.filesData[files.trash.DeletedF[1].element].href === href2
|
|
|
|
|
&& typeof files.template[0] === "number"
|
|
|
|
|
&& typeof files.filesData[files.template[0]] === "object"
|
|
|
|
|
&& !files.filesData[files.template[0]].filename
|
|
|
|
|
&& files.filesData[files.template[0]].href === href3
|
|
|
|
|
&& typeof fileId2 === "number"
|
|
|
|
|
&& typeof files.filesData[fileId2] === "object"
|
|
|
|
|
&& files.filesData[fileId2].filename === "Trash"
|
|
|
|
|
&& files.filesData[fileId2].href === href4;
|
|
|
|
|
return cb(res);
|
|
|
|
|
};
|
|
|
|
|
fo.migrate(todo);
|
|
|
|
|
}, "DRIVE4: migration and fixFiles with a pad in trash not root");
|
|
|
|
|
|
|
|
|
|
// userObject Tests
|
|
|
|
|