Don't delete the file anymore to replace it in the UI, just overwrite it

This commit is contained in:
Michael Gapczynski 2012-09-05 22:13:50 -04:00
parent a5211e31bc
commit 837eb1871d
3 changed files with 16 additions and 17 deletions

View File

@ -240,22 +240,17 @@ var FileList={
}, },
finishReplace:function() { finishReplace:function() {
if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) { if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) {
// Delete the file being replaced and rename the replacement $.ajax({url: OC.filePath('files', 'ajax', 'rename.php'), async: false, data: { dir: $('#dir').val(), newname: FileList.replaceNewName, file: FileList.replaceOldName }, success: function(result) {
FileList.deleteCanceled = false; if (result && result.status == 'success') {
FileList.deleteFiles = [FileList.replaceNewName]; $('tr').filterAttr('data-replace', 'true').removeAttr('data-replace');
FileList.finishDelete(function() { } else {
$.ajax({url: OC.filePath('files', 'ajax', 'rename.php'), async: false, data: { dir: $('#dir').val(), newname: FileList.replaceNewName, file: FileList.replaceOldName }, success: function(result) { OC.dialogs.alert(result.data.message, 'Error moving file');
if (result && result.status == 'success') { }
$('tr').filterAttr('data-replace', 'true').removeAttr('data-replace'); FileList.replaceCanceled = true;
} else { FileList.replaceOldName = null;
OC.dialogs.alert(result.data.message, 'Error moving file'); FileList.replaceNewName = null;
} FileList.lastAction = null;
FileList.replaceCanceled = true; }});
FileList.replaceOldName = null;
FileList.replaceNewName = null;
FileList.lastAction = null;
}});
}, true);
} }
}, },
do_delete:function(files){ do_delete:function(files){

View File

@ -155,6 +155,10 @@ class OC_FileCache{
if($root===false){ if($root===false){
$root=OC_Filesystem::getRoot(); $root=OC_Filesystem::getRoot();
} }
// If replacing an existing file, delete the file
if (self::inCache($newPath, $root)) {
self::delete($newPath, $root);
}
$oldPath=$root.$oldPath; $oldPath=$root.$oldPath;
$newPath=$root.$newPath; $newPath=$root.$newPath;
$newParent=self::getParentId($newPath); $newParent=self::getParentId($newPath);

View File

@ -202,7 +202,7 @@ 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') && !OC_Filesystem::file_exists($targetDir.'/'.$target)){ if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')){
$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);