summaryrefslogtreecommitdiffstats
path: root/files/js/files.js
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-04-15 17:30:07 +0200
committerRobin Appelman <icewind@owncloud.com>2012-04-15 17:34:53 +0200
commit8ecddb5bc311a7d9bb5def6783b8a71f09a8daa3 (patch)
tree4a5e65e7a31404ea5465f75d895b2bd95e93a77b /files/js/files.js
parent74ba09f95c57bc0cc8d7e8617cefe26f13054799 (diff)
downloadnextcloud-server-8ecddb5bc311a7d9bb5def6783b8a71f09a8daa3.tar.gz
nextcloud-server-8ecddb5bc311a7d9bb5def6783b8a71f09a8daa3.zip
create a new filename when the uploaded file already exist
Diffstat (limited to 'files/js/files.js')
-rw-r--r--files/js/files.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/files/js/files.js b/files/js/files.js
index 2d943d85cd4..3ce95f992d0 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -211,12 +211,12 @@ $(document).ready(function() {
var size=t('files','Pending');
}
if(files){
- FileList.addFile(files[i].name,size,date,true);
+ FileList.addFile(getUniqueName(files[i].name),size,date,true);
}
}
}else{
var filename=this.value.split('\\').pop(); //ie prepends C:\fakepath\ in front of the filename
- FileList.addFile(filename,'Pending',date,true);
+ FileList.addFile(getUniqueName(filename),'Pending',date,true);
}
//clone the upload form and hide the new one to allow users to start a new upload while the old one is still uploading
@@ -570,3 +570,22 @@ function getMimeIcon(mime, ready){
}
}
getMimeIcon.cache={};
+
+function getUniqueName(name){
+ if($('tr').filterAttr('data-file',name).length>0){
+ var parts=name.split('.');
+ var extension=parts.pop();
+ var base=parts.join('.');
+ numMatch=base.match(/\((\d+)\)/);
+ var num=2;
+ if(numMatch && numMatch.length>0){
+ num=parseInt(numMatch[numMatch.length-1])+1;
+ base=base.split('(')
+ base.pop();
+ base=base.join('(').trim();
+ }
+ name=base+' ('+num+').'+extension;
+ return getUniqueName(name);
+ }
+ return name;
+}