Do not show error if item is dropped on itself

This commit is contained in:
Johannes Zellner
2021-03-02 16:51:21 +01:00
parent a79c435bdc
commit 44ce9024eb

View File

@@ -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;