From 0d996b8ed43941003133d9f23244648286a57310 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 21 Feb 2019 17:40:34 +0100 Subject: [PATCH] Remove duplicates when migrating anon drive into user drive --- www/common/mergeDrive.js | 4 +++- www/common/migrate-user-object.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/www/common/mergeDrive.js b/www/common/mergeDrive.js index 396798d24..9247656e1 100644 --- a/www/common/mergeDrive.js +++ b/www/common/mergeDrive.js @@ -65,7 +65,9 @@ define([ if (!proxy.FS_hashes || !Array.isArray(proxy.FS_hashes)) { proxy.FS_hashes = []; } - proxy.FS_hashes.push(fsHash); + if (proxy.FS_hashes.indexOf(fsHash) === -1) { + proxy.FS_hashes.push(fsHash); + } if (typeof(cb) === "function") { Realtime.whenRealtimeSyncs(proxyData.realtime, cb); } diff --git a/www/common/migrate-user-object.js b/www/common/migrate-user-object.js index 2f1ea5e88..faef141a0 100644 --- a/www/common/migrate-user-object.js +++ b/www/common/migrate-user-object.js @@ -176,6 +176,16 @@ define([ if (version < 7) { addRoHref(); } + }).nThen(function () { + // Migration 8: remove duplicate entries in proxy.FS_hashes (list of migrated anon drives) + var fixDuplicate = function () { + userObject.FS_hashes = Util.deduplicateString(userObject.FS_hashes); + }; + if (version < 8) { + fixDuplicate(); + Feedback.send('Migrate-8', true); + userObject.version = version = 8; + } /*}).nThen(function (waitFor) { // Test progress bar in the loading screen var i = 0;