diff --git a/www/common/mergeDrive.js b/www/common/mergeDrive.js index ce3e0b157..0cbe312bf 100644 --- a/www/common/mergeDrive.js +++ b/www/common/mergeDrive.js @@ -111,12 +111,14 @@ define([ var newFo = newData.fo; var oldRecentPads = parsed.drive[newFo.FILES_DATA]; var newRecentPads = proxy.drive[newFo.FILES_DATA]; - var newFiles = newFo.getFiles([newFo.FILES_DATA]); var oldFiles = oldFo.getFiles([newFo.FILES_DATA]); + var newHrefs = Object.keys(newRecentPads).map(function (id) { + return newRecentPads[id].href; + }); oldFiles.forEach(function (id) { var href = oldRecentPads[id].href; // Do not migrate a pad if we already have it, it would create a duplicate in the drive - if (newFiles.indexOf(id) !== -1) { return; } + if (newHrefs.indexOf(href) !== -1) { return; } // If we have a stronger version, do not add the current href if (Cryptpad.findStronger(href, newRecentPads)) { return; } // If we have a weaker version, replace the href by the new one diff --git a/www/common/userObject.js b/www/common/userObject.js index 3f4ab7dd6..ddacbb806 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -456,7 +456,7 @@ define([ }; exp.getRecentPads = function () { var allFiles = files[FILES_DATA]; - var sorted = Object.keys(allFiles) + var sorted = Object.keys(allFiles).filter(function (a) { return allFiles[a]; }) .sort(function (a,b) { return allFiles[a].atime < allFiles[b].atime; }) @@ -1037,20 +1037,6 @@ define([ } }); }; - var migrateAttributes = function (el, id, parsed) { - // Migrate old pad attributes - ['userid', 'previewMode'].forEach(function (attr) { - var key = parsed.hash + '.' + attr; - var key2 = parsed.hash.slice(0,-1) + '.' + attr;// old pads not ending with / - if (typeof(files[key]) !== "undefined" || typeof(files[key2]) !== "undefined") { - debug("Migrating pad attribute", attr, "for pad", id); - el[attr] = files[key] || files[key2]; - delete files[key]; - delete files[key2]; - } - }); - // Migration done - }; var fixFilesData = function () { if (typeof files[FILES_DATA] !== "object") { debug("OLD_FILES_DATA was not an object"); files[FILES_DATA] = {}; } var fd = files[FILES_DATA]; @@ -1077,8 +1063,6 @@ define([ continue; } - migrateAttributes(el, id, parsed); - if ((Cryptpad.isLoggedIn() || config.testMode) && rootFiles.indexOf(id) === -1) { debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", id, el); var newName = Cryptpad.createChannelId(); diff --git a/www/register/main.js b/www/register/main.js index 7de37e8bf..1b7103cac 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -85,6 +85,8 @@ define([ Cryptpad.whenRealtimeSyncs(result.realtime, function () { Cryptpad.login(result.userHash, result.userName, function () { registering = false; + /* + FIXME: migration and readme not working if not redirected to drive if (sessionStorage.redirectTo) { var h = sessionStorage.redirectTo; var parser = document.createElement('a'); @@ -95,6 +97,7 @@ define([ return; } } + */ window.location.href = '/drive/'; }); });