[Pkg-owncloud-commits] [owncloud] 132/145: don't overwrite keys if rename was done by a stream copy

David Prévot taffit at moszumanska.debian.org
Wed Feb 26 16:27:48 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 9183ade655d5b77ed4300a73f068685c2260fd8a
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Mon Feb 24 13:56:53 2014 +0100

    don't overwrite keys if rename was done by a stream copy
---
 apps/files_encryption/hooks/hooks.php | 17 +++++++++++++----
 lib/private/files/view.php            |  2 ++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 50f322d..9f34d10 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -501,11 +501,20 @@ class Hooks {
 	 * @param array $params with the old path and the new path
 	 */
 	public static function preRename($params) {
-		$util = new Util(new \OC_FilesystemView('/'), \OCP\User::getUser());
+		$user = \OCP\User::getUser();
+		$view = new \OC_FilesystemView('/');
+		$util = new Util($view, $user);
 		list($ownerOld, $pathOld) = $util->getUidAndFilename($params['oldpath']);
-		self::$renamedFiles[$params['oldpath']] = array(
-			'uid' => $ownerOld,
-			'path' => $pathOld);
+
+		// we only need to rename the keys if the rename happens on the same mountpoint
+		// otherwise we perform a stream copy, so we get a new set of keys
+		$mp1 = $view->getMountPoint('/' . $user . '/files/' . $params['oldpath']);
+		$mp2 = $view->getMountPoint('/' . $user . '/files/' . $params['newpath']);
+		if ($mp1 === $mp2) {
+			self::$renamedFiles[$params['oldpath']] = array(
+				'uid' => $ownerOld,
+				'path' => $pathOld);
+		}
 	}
 
 	/**
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 8893911..a7e3f53 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -531,6 +531,8 @@ class View {
 						$source = $this->fopen($path1 . $postFix1, 'r');
 						$target = $this->fopen($path2 . $postFix2, 'w');
 						list($count, $result) = \OC_Helper::streamCopy($source, $target);
+						fclose($source);
+						fclose($target);
 					}
 				}
 				if ($this->shouldEmitHooks() && $result !== false) {

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