[Pkg-owncloud-commits] [owncloud] 12/123: use cross storage move when renaming the part file during webdav put

David Prévot taffit at moszumanska.debian.org
Tue May 19 23:55:08 UTC 2015


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

taffit pushed a commit to branch stable8
in repository owncloud.

commit 06a65fab13fca510cbc5213d3353335046ba9445
Author: Robin Appelman <icewind at owncloud.com>
Date:   Thu May 7 14:28:31 2015 +0200

    use cross storage move when renaming the part file during webdav put
---
 lib/private/connector/sabre/file.php | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 8ff5577..cfa1cac 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -99,8 +99,8 @@ class File extends Node implements IFile {
 			return $this->createFileChunked($data);
 		}
 
-		list($storage) = $this->fileView->resolvePath($this->path);
-		$needsPartFile = $this->needsPartFile($storage) && (strlen($this->path) > 1);
+		list($partStorage) = $this->fileView->resolvePath($this->path);
+		$needsPartFile = $this->needsPartFile($partStorage) && (strlen($this->path) > 1);
 
 		if ($needsPartFile) {
 			// mark file as partial while uploading (ignored by the scanner)
@@ -110,14 +110,16 @@ class File extends Node implements IFile {
 			$partFilePath = $this->path;
 		}
 
+		// the part file and target file might be on a different storage in case of a single file storage (e.g. single file share)
+		/** @var \OC\Files\Storage\Storage $partStorage */
+		list($partStorage, $internalPartPath) = $this->fileView->resolvePath($partFilePath);
 		/** @var \OC\Files\Storage\Storage $storage */
-		list($storage, $internalPartPath) = $this->fileView->resolvePath($partFilePath);
-		list(, $internalPath) = $this->fileView->resolvePath($this->path);
+		list($storage, $internalPath) = $this->fileView->resolvePath($this->path);
 		try {
-			$target = $storage->fopen($internalPartPath, 'wb');
+			$target = $partStorage->fopen($internalPartPath, 'wb');
 			if ($target === false) {
 				\OC_Log::write('webdav', '\OC\Files\Filesystem::fopen() failed', \OC_Log::ERROR);
-				$storage->unlink($internalPartPath);
+				$partStorage->unlink($internalPartPath);
 				// because we have no clue about the cause we can only throw back a 500/Internal Server Error
 				throw new Exception('Could not write file contents');
 			}
@@ -130,7 +132,7 @@ class File extends Node implements IFile {
 			if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['REQUEST_METHOD'] !== 'LOCK') {
 				$expected = $_SERVER['CONTENT_LENGTH'];
 				if ($count != $expected) {
-					$storage->unlink($internalPartPath);
+					$partStorage->unlink($internalPartPath);
 					throw new BadRequest('expected filesize ' . $expected . ' got ' . $count);
 				}
 			}
@@ -162,11 +164,11 @@ class File extends Node implements IFile {
 			if ($needsPartFile) {
 				// rename to correct path
 				try {
-					$renameOkay = $storage->rename($internalPartPath, $internalPath);
+					$renameOkay = $storage->moveFromStorage($partStorage, $internalPartPath, $internalPath);
 					$fileExists = $storage->file_exists($internalPath);
 					if ($renameOkay === false || $fileExists === false) {
 						\OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
-						$storage->unlink($internalPartPath);
+						$partStorage->unlink($internalPartPath);
 						throw new Exception('Could not rename part file to final file');
 					}
 				} catch (\OCP\Files\LockNotAcquiredException $e) {
@@ -176,7 +178,7 @@ class File extends Node implements IFile {
 			}
 
 			// since we skipped the view we need to scan and emit the hooks ourselves
-			$storage->getScanner()->scanFile($internalPath);
+			$partStorage->getScanner()->scanFile($internalPath);
 
 			$view = \OC\Files\Filesystem::getView();
 			if ($view) {

-- 
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