diff --git a/src/js/client.js b/src/js/client.js index 2c2a4aa96..ba1618c17 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -2830,9 +2830,12 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.filesCopy = function (id, type, path, newPath, callback) { + var that = this; + var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; put('/api/v1/' + objpath + '/files/' + path, { action: 'copy', newFilePath: decodeURIComponent(newPath) }, {}, function (error, data, status) { + if (error && error.statusCode === 409) return that.filesCopy(id, type, path, newPath + '-copy', callback); if (error) return callback(error); if (status !== 200) return callback(new ClientError(status, data)); diff --git a/src/js/filemanager.js b/src/js/filemanager.js index 6cfaa62c4..6ab97addd 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -512,7 +512,7 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl async.eachLimit(collectedFiles, 5, function (entry, callback) { var newFilePath = sanitize($scope.cwd + '/' + ((destinationEntry && destinationEntry.isDirectory) ? destinationEntry.fileName : '') + '/' + entry.fullFilePath); - // TODO this will NOT overwrite files in destination! + // This will NOT overwrite but finds a unique new name to copy to Client.filesCopy($scope.id, $scope.type, entry.fullFilePath, newFilePath, callback); }, function (error) { if (error) return Client.error(error);