From 138ad17e3e1f5d8933325e6bbb6943cd3d541cc6 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 17:09:26 +0200 Subject: [PATCH] Fix 'import local pads' in settings creating duplicates --- www/common/mergeDrive.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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