|
|
@@ -2284,7 +2284,40 @@ |
|
|
|
// not overwrite it |
|
|
|
targetPath = targetPath + '/'; |
|
|
|
} |
|
|
|
self.filesClient.copy(dir + fileName, targetPath + fileName) |
|
|
|
let targetPathAndName = targetPath + fileName; |
|
|
|
if ((dir + fileName) === targetPathAndName) { |
|
|
|
let dotIndex = targetPathAndName.indexOf("."); |
|
|
|
if ( dotIndex > 1) { |
|
|
|
let leftPartOfName = targetPathAndName.substr(0, dotIndex); |
|
|
|
let fileNumber = leftPartOfName.match(/\d+/); |
|
|
|
if (isNaN(fileNumber) ) { |
|
|
|
fileNumber++; |
|
|
|
targetPathAndName = targetPathAndName.replace(/(?=\.[^.]+$)/g, "_" + fileNumber); |
|
|
|
} |
|
|
|
else { |
|
|
|
// check if we have other files with _x and the same name |
|
|
|
let maxNum = 1; |
|
|
|
if (self.files !== null) { |
|
|
|
leftPartOfName = leftPartOfName.replace("/", ""); |
|
|
|
leftPartOfName = leftPartOfName.replace(/_\d+/,""); |
|
|
|
// find the last file with the number extention and add one to the new name |
|
|
|
for (let j = 0; j < self.files.length; j++) { |
|
|
|
const cName = self.files[j].name; |
|
|
|
if (cName.indexOf(leftPartOfName) > -1) { |
|
|
|
let cFileNumber = cName.match(/_(\d+)/); |
|
|
|
if (cFileNumber && parseInt(cFileNumber[1]) >= maxNum) { |
|
|
|
maxNum = parseInt(cFileNumber[1]) + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
targetPathAndName = targetPathAndName.replace(/_\d+/,""); |
|
|
|
} |
|
|
|
// Create the new file name with _x at the end |
|
|
|
targetPathAndName = targetPathAndName.replace(/(?=\.[^.]+$)/g, "_" + maxNum); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
self.filesClient.copy(dir + fileName, targetPathAndName) |
|
|
|
.done(function () { |
|
|
|
filesToNotify.push(fileName); |
|
|
|
|
|
|
@@ -2298,6 +2331,7 @@ |
|
|
|
oldFile.data('size', newSize); |
|
|
|
oldFile.find('td.filesize').text(OC.Util.humanFileSize(newSize)); |
|
|
|
} |
|
|
|
self.reload(); |
|
|
|
}) |
|
|
|
.fail(function(status) { |
|
|
|
if (status === 412) { |