From fdd51ec18d3166e2ef835f1332c7a6f6072cc809 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 24 Apr 2017 15:38:03 +0200 Subject: [PATCH] Don't remove a folder moved into unsorted or into itself --- www/common/userObject.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/www/common/userObject.js b/www/common/userObject.js index 6a70a3622..ca2bae258 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -460,12 +460,6 @@ define([ var element = find(elementPath); var newParent = find(newParentPath); - // Never move a folder in one of its children - if (isSubpath(newParentPath, elementPath)) { - log(Messages.fo_moveFolderToChildError); - return; - } - // Move to Trash if (isPathIn(newParentPath, [TRASH])) { if (!elementPath || elementPath.length < 2 || elementPath[0] === TRASH) { @@ -518,9 +512,15 @@ define([ paths.forEach(function (p) { var parentPath = p.slice(); parentPath.pop(); - if (comparePath(parentPath, newPath)) { return; } - copyElement(p, newPath); - toRemove.push(p); + if (comparePath(parentPath, newPath)) { return; } + if (isSubpath(newPath, p)) { + log(Messages.fo_moveFolderToChildError); + return; + } + // Try to copy, and if success, remove the element from the old location + if (copyElement(p, newPath)) { + toRemove.push(p); + } }); exp.delete(toRemove, cb); };