aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorIdo Green <igreen@netflix.com>2018-10-08 11:11:29 -0700
committerMorris Jobke <hey@morrisjobke.de>2018-11-19 13:57:23 +0100
commit313aee91ca073acb734d7e3029d6b6ce0ce1a384 (patch)
tree2eca76769c12aeed42f2fc01cc4e1605e11f2768 /apps
parent48d74482c1053a9531ce037207d8e5b9eab09583 (diff)
downloadnextcloud-server-313aee91ca073acb734d7e3029d6b6ce0ce1a384.tar.gz
nextcloud-server-313aee91ca073acb734d7e3029d6b6ce0ce1a384.zip
Per the last comment on having only (copy) for the first one
Signed-off-by: Ido Green <greenido@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/filelist.js24
1 files changed, 19 insertions, 5 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 43909fc3942..e0edb15884f 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -2295,25 +2295,39 @@
targetPathAndName = targetPathAndName.replace(/(?=\.[^.]+$)/g, " (copy " + fileNumber + ")");
}
else {
- // check if we have other files with _x and the same name
+ // Check if we have other files with 'copy X' and the same name
let maxNum = 1;
if (self.files !== null) {
leftPartOfName = leftPartOfName.replace("/", "");
+ leftPartOfName = leftPartOfName.replace(/\(copy\)/,"");
leftPartOfName = leftPartOfName.replace(/\(copy \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(/\(copy (\d+)\)/);
- if (cFileNumber && parseInt(cFileNumber[1]) >= maxNum) {
- maxNum = parseInt(cFileNumber[1]) + 1;
+ if (cName.indexOf("(copy)") > 0) {
+ targetPathAndName = targetPathAndName.replace(/ \(copy\)/,"");
+ if (maxNum == 1) {
+ maxNum = 2;
+ }
+ }
+ else {
+ let cFileNumber = cName.match(/\(copy (\d+)\)/);
+ if (cFileNumber && parseInt(cFileNumber[1]) >= maxNum) {
+ maxNum = parseInt(cFileNumber[1]) + 1;
+ }
}
}
}
targetPathAndName = targetPathAndName.replace(/ \(copy \d+\)/,"");
}
// Create the new file name with _x at the end
- targetPathAndName = targetPathAndName.replace(/(?=\.[^.]+$)/g, " (copy " + maxNum +")");
+ // Start from 2 per a special request of the 'standard'
+ let extntionName = " (copy " + maxNum +")";
+ if (maxNum == 1) {
+ extntionName = " (copy)";
+ }
+ targetPathAndName = targetPathAndName.replace(/(?=\.[^.]+$)/g, extntionName);
}
}
}