Add more migration options

This commit is contained in:
yflory
2019-10-28 18:22:42 +01:00
parent f6bbe70f3c
commit 176e667128
4 changed files with 41 additions and 23 deletions

View File

@@ -63,6 +63,28 @@ define([
});
};
// XXX only needed if we want a manual migration from the share modal...
SF.migrate = function (channel) {
var sf = allSharedFolders[channel];
if (!sf) { return; }
var clients = sf.teams;
if (!Array.isArray(clients) || !clients.length) { return; }
var c = clients[0];
// No secondaryKey? ==> already migrated ==> abort
if (!c.secondaryKey) { return; }
var f = Util.find(c, ['store', 'manager', 'folders', c.id]);
// Can't find the folder: abort
if (!f) { return; }
// Already migrated: abort
if (!f.proxy || f.proxy.version) { return; }
f.userObject.migrateReadOnly(function () {
clients.forEach(function (obj) {
var uo = Util.find(obj, ['store', 'manager', 'folders', obj.id, 'userObject']);
uo.setReadOnly(false, obj.secondarykey);
});
});
};
SF.load = function (config, id, data, _cb) {
var cb = Util.once(_cb);
var network = config.network;

View File

@@ -478,28 +478,13 @@ define([
files.migrateRo = 1;
var next = function () {
var copy = JSON.parse(JSON.stringify(files));
exp.reencrypt(null, config.editKey, copy);
// XXX test migration again
/*
Object.keys(copy[FILES_DATA]).forEach(function (id) {
var data = copy[FILES_DATA][id] || {};
// If this pad has a visible href, encrypt it
// "&& data.roHref" is here to make sure this is not a "file"
if (data.href && data.roHref && !data.fileType && data.href.indexOf('#') !== -1) {
data.href = exp.cryptor.encrypt(data.href);
}
exp.reencrypt(config.editKey, config.editKey, copy);
Object.keys(copy).forEach(function (k) {
files[k] = copy[k];
});
Object.keys(copy[SHARED_FOLDERS] || {}).forEach(function (id) {
var data = copy[SHARED_FOLDERS][id] || {};
// If this folder has a visible href, encrypt it
if (data.href && data.roHref && !data.fileType && data.href.indexOf('#') !== -1) {
data.href = exp.cryptor.encrypt(data.href);
}
});*/
copy.version = 2;
delete copy.migrateRo;
files.version = 2;
delete files.migrateRo;
files = copy;
onSync(cb);
};
onSync(next);