|
|
|
@ -1,12 +1,18 @@
|
|
|
|
|
define(['/common/common-feedback.js'], function (Feedback) {
|
|
|
|
|
define([
|
|
|
|
|
'/common/common-feedback.js',
|
|
|
|
|
'/common/common-hash.js',
|
|
|
|
|
'/common/common-util.js',
|
|
|
|
|
'/bower_components/nthen/index.js',
|
|
|
|
|
], function (Feedback, Hash, Util, nThen) {
|
|
|
|
|
// Start migration check
|
|
|
|
|
// Versions:
|
|
|
|
|
// 1: migrate pad attributes
|
|
|
|
|
// 2: migrate indent settings (codemirror)
|
|
|
|
|
|
|
|
|
|
return function (userObject) {
|
|
|
|
|
return function (userObject, cb) {
|
|
|
|
|
var version = userObject.version || 0;
|
|
|
|
|
|
|
|
|
|
nThen(function () {
|
|
|
|
|
// DEPRECATED
|
|
|
|
|
// Migration 1: pad attributes moved to filesData
|
|
|
|
|
var migratePadAttributesToData = function () {
|
|
|
|
@ -15,7 +21,7 @@ define(['/common/common-feedback.js'], function (Feedback) {
|
|
|
|
|
if (version < 1) {
|
|
|
|
|
migratePadAttributesToData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
// Migration 2: global attributes from root to 'settings' subobjects
|
|
|
|
|
var migrateAttributes = function () {
|
|
|
|
|
var drawer = 'cryptpad.userlist-drawer';
|
|
|
|
@ -49,9 +55,7 @@ define(['/common/common-feedback.js'], function (Feedback) {
|
|
|
|
|
Feedback.send('Migrate-2', true);
|
|
|
|
|
userObject.version = version = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
// Migration 3: language from localStorage to settings
|
|
|
|
|
var migrateLanguage = function () {
|
|
|
|
|
if (!localStorage.CRYPTPAD_LANG) { return; }
|
|
|
|
@ -63,9 +67,7 @@ define(['/common/common-feedback.js'], function (Feedback) {
|
|
|
|
|
Feedback.send('Migrate-3', true);
|
|
|
|
|
userObject.version = version = 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
// Migration 4: allowUserFeedback to settings
|
|
|
|
|
var migrateFeedback = function () {
|
|
|
|
|
var settings = userObject.settings = userObject.settings || {};
|
|
|
|
@ -80,9 +82,7 @@ define(['/common/common-feedback.js'], function (Feedback) {
|
|
|
|
|
Feedback.send('Migrate-4', true);
|
|
|
|
|
userObject.version = version = 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
// Migration 5: dates to Number
|
|
|
|
|
var migrateDates = function () {
|
|
|
|
|
var data = userObject.drive && userObject.drive.filesData;
|
|
|
|
@ -102,5 +102,41 @@ define(['/common/common-feedback.js'], function (Feedback) {
|
|
|
|
|
Feedback.send('Migrate-5', true);
|
|
|
|
|
userObject.version = version = 5;
|
|
|
|
|
}
|
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
|
console.log('start');
|
|
|
|
|
var addChannelId = function () {
|
|
|
|
|
var data = userObject.drive.filesData;
|
|
|
|
|
var el, parsed;
|
|
|
|
|
var n = nThen(function () {});
|
|
|
|
|
Object.keys(data).forEach(function (k) {
|
|
|
|
|
n = n.nThen(function (w) {
|
|
|
|
|
setTimeout(w(function () {
|
|
|
|
|
el = data[k];
|
|
|
|
|
parsed = Hash.parsePadUrl(el.href);
|
|
|
|
|
if (!el.href) { return; }
|
|
|
|
|
if (!el.channel) {
|
|
|
|
|
if (parsed.hashData && parsed.hashData.type === "file") {
|
|
|
|
|
// PASSWORD_FILES
|
|
|
|
|
el.channel = Util.base64ToHex(parsed.hashData.channel);
|
|
|
|
|
} else {
|
|
|
|
|
var secret = Hash.getSecrets(parsed.type, parsed.hash, el.password);
|
|
|
|
|
el.channel = secret.channel;
|
|
|
|
|
}
|
|
|
|
|
console.log('Adding missing channel in filesData ', el.channel);
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
n.nThen(waitFor());
|
|
|
|
|
};
|
|
|
|
|
if (version < 6) {
|
|
|
|
|
addChannelId();
|
|
|
|
|
Feedback.send('Migrate-6', true);
|
|
|
|
|
userObject.version = version = 6;
|
|
|
|
|
}
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
console.log('done');
|
|
|
|
|
cb();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|