]> source.dussan.org Git - nextcloud-server.git/commitdiff
Removed special handling of part files in shared storage rename
authorVincent Petry <pvince81@owncloud.com>
Wed, 8 Jan 2014 17:43:20 +0000 (18:43 +0100)
committerVincent Petry <pvince81@owncloud.com>
Wed, 8 Jan 2014 17:43:20 +0000 (18:43 +0100)
This fixes the issue introduced by the transfer id which itself wasn't
taken into account by the shortcut code for part file in the shared
storage class.

apps/files_sharing/lib/sharedstorage.php
lib/private/connector/sabre/file.php

index 3116cd717fb0affd8e06d2ca86aa04076798c00e..6b4db9763f5a884f0422c2e524ba17a1937ec3d0 100644 (file)
@@ -293,29 +293,20 @@ class Shared extends \OC\Files\Storage\Common {
        }
 
        public function rename($path1, $path2) {
-               // Check for partial files
-               if (pathinfo($path1, PATHINFO_EXTENSION) === 'part') {
-                       if ($oldSource = $this->getSourcePath($path1)) {
+               // Renaming/moving is only allowed within shared folders
+               $pos1 = strpos($path1, '/', 1);
+               $pos2 = strpos($path2, '/', 1);
+               if ($pos1 !== false && $pos2 !== false && ($oldSource = $this->getSourcePath($path1))) {
+                       $newSource = $this->getSourcePath(dirname($path2)) . '/' . basename($path2);
+                       // Within the same folder, we only need UPDATE permissions
+                       if (dirname($path1) == dirname($path2) and $this->isUpdatable($path1)) {
                                list($storage, $oldInternalPath) = \OC\Files\Filesystem::resolvePath($oldSource);
-                               $newInternalPath = substr($oldInternalPath, 0, -5);
+                               list(, $newInternalPath) = \OC\Files\Filesystem::resolvePath($newSource);
                                return $storage->rename($oldInternalPath, $newInternalPath);
-                       }
-               } else {
-                       // Renaming/moving is only allowed within shared folders
-                       $pos1 = strpos($path1, '/', 1);
-                       $pos2 = strpos($path2, '/', 1);
-                       if ($pos1 !== false && $pos2 !== false && ($oldSource = $this->getSourcePath($path1))) {
-                               $newSource = $this->getSourcePath(dirname($path2)) . '/' . basename($path2);
-                               // Within the same folder, we only need UPDATE permissions
-                               if (dirname($path1) == dirname($path2) and $this->isUpdatable($path1)) {
-                                       list($storage, $oldInternalPath) = \OC\Files\Filesystem::resolvePath($oldSource);
-                                       list(, $newInternalPath) = \OC\Files\Filesystem::resolvePath($newSource);
-                                       return $storage->rename($oldInternalPath, $newInternalPath);
-                                       // otherwise DELETE and CREATE permissions required
-                               } elseif ($this->isDeletable($path1) && $this->isCreatable(dirname($path2))) {
-                                       $rootView = new \OC\Files\View('');
-                                       return $rootView->rename($oldSource, $newSource);
-                               }
+                               // otherwise DELETE and CREATE permissions required
+                       } elseif ($this->isDeletable($path1) && $this->isCreatable(dirname($path2))) {
+                               $rootView = new \OC\Files\View('');
+                               return $rootView->rename($oldSource, $newSource);
                        }
                }
                return false;
index 53524ec9e54914a56dfb04e32f0f37e2bf25a861..c3b59007295b63ed9f0c9f79cd1f4970eb77c4be 100644 (file)
@@ -242,7 +242,10 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
                        $fileExists = $fs->file_exists($targetPath);
                        if ($renameOkay === false || $fileExists === false) {
                                \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
-                               $fs->unlink($targetPath);
+                               // only delete if an error occurred and the target file was already created
+                               if ($fileExists) {
+                                       $fs->unlink($targetPath);
+                               }
                                throw new Sabre_DAV_Exception();
                        }