- when creating a new text file or directory which name already exist use the same pattern as for file uploads in such a case (add a (N) to the name)
- don't allow renaming if a file/directory with the name already exists
This commit is contained in:
parent
60ec46f706
commit
b95996c02c
|
@ -451,7 +451,7 @@ $(document).ready(function() {
|
||||||
$(this).append(input);
|
$(this).append(input);
|
||||||
input.focus();
|
input.focus();
|
||||||
input.change(function(){
|
input.change(function(){
|
||||||
var name=$(this).val();
|
var name=getUniqueName($(this).val());
|
||||||
if(type != 'web' && name.indexOf('/')!=-1){
|
if(type != 'web' && name.indexOf('/')!=-1){
|
||||||
$('#notification').text(t('files','Invalid name, \'/\' is not allowed.'));
|
$('#notification').text(t('files','Invalid name, \'/\' is not allowed.'));
|
||||||
$('#notification').fadeIn();
|
$('#notification').fadeIn();
|
||||||
|
@ -496,6 +496,7 @@ $(document).ready(function() {
|
||||||
}else{//or the domain
|
}else{//or the domain
|
||||||
localName=(localName.match(/:\/\/(.[^/]+)/)[1]).replace('www.','');
|
localName=(localName.match(/:\/\/(.[^/]+)/)[1]).replace('www.','');
|
||||||
}
|
}
|
||||||
|
localName = getUniqueName(localName);
|
||||||
$.post(
|
$.post(
|
||||||
OC.filePath('files','ajax','newfile.php'),
|
OC.filePath('files','ajax','newfile.php'),
|
||||||
{dir:$('#dir').val(),source:name,filename:localName},
|
{dir:$('#dir').val(),source:name,filename:localName},
|
||||||
|
@ -737,7 +738,10 @@ getMimeIcon.cache={};
|
||||||
function getUniqueName(name){
|
function getUniqueName(name){
|
||||||
if($('tr').filterAttr('data-file',name).length>0){
|
if($('tr').filterAttr('data-file',name).length>0){
|
||||||
var parts=name.split('.');
|
var parts=name.split('.');
|
||||||
var extension=parts.pop();
|
var extension = "";
|
||||||
|
if (parts.length > 1) {
|
||||||
|
extension=parts.pop();
|
||||||
|
}
|
||||||
var base=parts.join('.');
|
var base=parts.join('.');
|
||||||
numMatch=base.match(/\((\d+)\)/);
|
numMatch=base.match(/\((\d+)\)/);
|
||||||
var num=2;
|
var num=2;
|
||||||
|
@ -747,7 +751,10 @@ function getUniqueName(name){
|
||||||
base.pop();
|
base.pop();
|
||||||
base=base.join('(').trim();
|
base=base.join('(').trim();
|
||||||
}
|
}
|
||||||
name=base+' ('+num+').'+extension;
|
name=base+' ('+num+')';
|
||||||
|
if (extension) {
|
||||||
|
name = name+'.'+extension;
|
||||||
|
}
|
||||||
return getUniqueName(name);
|
return getUniqueName(name);
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
|
|
@ -167,10 +167,12 @@ class OC_Files {
|
||||||
* @param file $target
|
* @param file $target
|
||||||
*/
|
*/
|
||||||
public static function move($sourceDir,$source,$targetDir,$target){
|
public static function move($sourceDir,$source,$targetDir,$target){
|
||||||
if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')){
|
if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared') && !OC_Filesystem::file_exists($tagetDir.'/'.$target)){
|
||||||
$targetFile=self::normalizePath($targetDir.'/'.$target);
|
$targetFile=self::normalizePath($targetDir.'/'.$target);
|
||||||
$sourceFile=self::normalizePath($sourceDir.'/'.$source);
|
$sourceFile=self::normalizePath($sourceDir.'/'.$source);
|
||||||
return OC_Filesystem::rename($sourceFile,$targetFile);
|
return OC_Filesystem::rename($sourceFile,$targetFile);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue