Don't remove a folder moved into unsorted or into itself

This commit is contained in:
yflory 2017-04-24 15:38:03 +02:00
parent 3e28d1b966
commit fdd51ec18d

View File

@ -460,12 +460,6 @@ define([
var element = find(elementPath); var element = find(elementPath);
var newParent = find(newParentPath); 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 // Move to Trash
if (isPathIn(newParentPath, [TRASH])) { if (isPathIn(newParentPath, [TRASH])) {
if (!elementPath || elementPath.length < 2 || elementPath[0] === TRASH) { if (!elementPath || elementPath.length < 2 || elementPath[0] === TRASH) {
@ -518,9 +512,15 @@ define([
paths.forEach(function (p) { paths.forEach(function (p) {
var parentPath = p.slice(); var parentPath = p.slice();
parentPath.pop(); parentPath.pop();
if (comparePath(parentPath, newPath)) { return; } if (comparePath(parentPath, newPath)) { return; }
copyElement(p, newPath); if (isSubpath(newPath, p)) {
toRemove.push(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); exp.delete(toRemove, cb);
}; };