diff --git a/src/js/filemanager.js b/src/js/filemanager.js index 8495682e5..900318d0e 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -219,13 +219,21 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl if (dataTransfer.getData('application/cloudron-filemanager')) { if ($scope.selected.length === 0) return; + var moved = 0; + // move files async.eachLimit($scope.selected, 5, function (entry, callback) { - var newFilePath = sanitize(targetFolder + '/' + entry.fileName); var oldFilePath = sanitize($scope.cwd + '/' + entry.fileName); + var newFilePath = sanitize(targetFolder + '/' + entry.fileName); + // if we drop the item on itself + if (oldFilePath === targetFolder) return callback(); + + // if nothing changes if (newFilePath === oldFilePath) return callback(); + moved++; + // TODO this will overwrite files in destination! Client.filesRename($scope.id, $scope.type, oldFilePath, newFilePath, callback); }, function (error) { @@ -233,7 +241,8 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl $scope.selected = []; - $scope.refresh(); + // only refresh if anything has changed + if (moved) $scope.refresh(); }); return;