]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't delete the file anymore to replace it in the UI, just overwrite it
authorMichael Gapczynski <mtgap@owncloud.com>
Thu, 6 Sep 2012 02:13:50 +0000 (22:13 -0400)
committerMichael Gapczynski <mtgap@owncloud.com>
Thu, 6 Sep 2012 02:13:50 +0000 (22:13 -0400)
apps/files/js/filelist.js
lib/filecache.php
lib/files.php

index a9e48f24052ef6797c0701f1736b10cb68b10f58..b777785f4d93f7bf8b00b7698ce7538d20874fa1 100644 (file)
@@ -240,22 +240,17 @@ var FileList={
        },
        finishReplace:function() {
                if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) {
-                       // Delete the file being replaced and rename the replacement
-                       FileList.deleteCanceled = false;
-                       FileList.deleteFiles = [FileList.replaceNewName];
-                       FileList.finishDelete(function() {
-                               $.ajax({url: OC.filePath('files', 'ajax', 'rename.php'), async: false, data: { dir: $('#dir').val(), newname: FileList.replaceNewName, file: FileList.replaceOldName }, success: function(result) {
-                                       if (result && result.status == 'success') {
-                                               $('tr').filterAttr('data-replace', 'true').removeAttr('data-replace');
-                                       } else {
-                                               OC.dialogs.alert(result.data.message, 'Error moving file');
-                                       }
-                                       FileList.replaceCanceled = true;
-                                       FileList.replaceOldName = null;
-                                       FileList.replaceNewName = null;
-                                       FileList.lastAction = null;
-                               }});
-                       }, true);
+                       $.ajax({url: OC.filePath('files', 'ajax', 'rename.php'), async: false, data: { dir: $('#dir').val(), newname: FileList.replaceNewName, file: FileList.replaceOldName }, success: function(result) {
+                               if (result && result.status == 'success') {
+                                       $('tr').filterAttr('data-replace', 'true').removeAttr('data-replace');
+                               } else {
+                                       OC.dialogs.alert(result.data.message, 'Error moving file');
+                               }
+                               FileList.replaceCanceled = true;
+                               FileList.replaceOldName = null;
+                               FileList.replaceNewName = null;
+                               FileList.lastAction = null;
+                       }});
                }
        },
        do_delete:function(files){
index 364b908bcfa7dd14eb3992f277105fdf7cbceda7..811e8a3e6a2efb3c5654d685331fb2cd709cc321 100644 (file)
@@ -155,6 +155,10 @@ class OC_FileCache{
                if($root===false){
                        $root=OC_Filesystem::getRoot();
                }
+               // If replacing an existing file, delete the file
+               if (self::inCache($newPath, $root)) {
+                       self::delete($newPath, $root);
+               }
                $oldPath=$root.$oldPath;
                $newPath=$root.$newPath;
                $newParent=self::getParentId($newPath);
index b8af5e04b71cdd465595215325493a54515fd116..00cbc63aba06ccf2ca9263aa17be98dac020c342 100644 (file)
@@ -202,7 +202,7 @@ class OC_Files {
        * @param file $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);
                        $sourceFile=self::normalizePath($sourceDir.'/'.$source);
                        return OC_Filesystem::rename($sourceFile,$targetFile);