[Pkg-owncloud-commits] [owncloud] 59/104: Removed special handling of part files in shared storage rename

David Prévot taffit at moszumanska.debian.org
Sat Jan 18 13:33:40 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit a711d4e39ab87cefdea3fbe128ba1e256aba15d5
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Wed Jan 8 18:43:20 2014 +0100

    Removed special handling of part files in shared storage rename
    
    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.
    
    Backport of 8eaa39f to stable6
---
 apps/files_sharing/lib/sharedstorage.php | 33 ++++++++++++--------------------
 lib/private/connector/sabre/file.php     |  5 ++++-
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 3116cd7..6b4db97 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -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;
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 295575f..ab77d0a 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -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();
 			}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list