[Pkg-owncloud-commits] [owncloud] 36/129: Fix preserving file ids when restoring a file with object storage

David Prévot taffit at moszumanska.debian.org
Thu Nov 5 01:04:20 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 ca811d3079353914196e1369e0052b40a0f53472
Author: Robin Appelman <icewind at owncloud.com>
Date:   Tue Oct 13 16:15:00 2015 +0200

    Fix preserving file ids when restoring a file with object storage
---
 apps/files_versions/lib/storage.php | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index fd51a54..ae86b67 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -347,7 +347,20 @@ class Storage {
 		$view->lockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
 		$view->lockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);
 
-		$result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2);
+		// TODO add a proper way of overwriting a file while maintaining file ids
+		if ($storage1->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage') || $storage2->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage')) {
+			$source = $storage1->fopen($internalPath1, 'r');
+			$target = $storage2->fopen($internalPath2, 'w');
+			list(, $result) = \OC_Helper::streamCopy($source, $target);
+			fclose($source);
+			fclose($target);
+
+			if ($result !== false) {
+				$storage1->unlink($internalPath1);
+			}
+		} else {
+			$result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2);
+		}
 
 		$view->unlockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
 		$view->unlockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);

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