[Pkg-owncloud-commits] [owncloud] 02/70: always use oc filesystem for rename operation

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:58 UTC 2014


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

taffit pushed a commit to annotated tag v6.0.5RC1
in repository owncloud.

commit b66d3632ea049695a56732ca84dd35abf57ac988
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Mon Jun 23 17:28:57 2014 +0200

    always use oc filesystem for rename operation
---
 apps/files_encryption/hooks/hooks.php | 20 ++++++++++----------
 apps/files_encryption/lib/helper.php  | 25 +++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 4bf9ef9..07502cd 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -574,19 +574,19 @@ class Hooks {
 			$oldKeyfilePath .= '.key';
 			$newKeyfilePath .= '.key';
 
-			// handle share-keys
+			// create destination folder if not exists
 			$localKeyPath = $view->getLocalFile($oldShareKeyPath);
-			$escapedPath = Helper::escapeGlobPattern($localKeyPath);
-			$matches = glob($escapedPath . '*.shareKey');
-			foreach ($matches as $src) {
-				$dst = \OC\Files\Filesystem::normalizePath(str_replace($pathOld, $pathNew, $src));
+			$newLocalKeyPath = \OC\Files\Filesystem::normalizePath(str_replace($pathOld, $pathNew, $localKeyPath));
+			if (!file_exists(dirname($newLocalKeyPath))) {
+				mkdir(dirname($newLocalKeyPath), 0750, true);
+			}
 
-				// create destination folder if not exists
-				if (!file_exists(dirname($dst))) {
-					mkdir(dirname($dst), 0750, true);
-				}
 
-				rename($src, $dst);
+			// handle share-keys
+			$matches = Helper::findShareKeys($oldShareKeyPath, $view);
+			foreach ($matches as $src) {
+				$dst = \OC\Files\Filesystem::normalizePath(str_replace($pathOld, $pathNew, $src));
+				$view->rename($src, $dst);
 			}
 
 		} else {
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php
index bb06a57..c21f788 100755
--- a/apps/files_encryption/lib/helper.php
+++ b/apps/files_encryption/lib/helper.php
@@ -430,6 +430,31 @@ class Helper {
 	}
 
 	/**
+	 * find all share keys for a given file
+	 * @param string $path to the file
+	 * @param \OC\Files\View $view view, relative to data/
+	 * @return array list of files, path relative to data/
+	 */
+	public static function findShareKeys($path, $view) {
+		$result = array();
+		$pathinfo = pathinfo($path);
+		$dirContent = $view->opendir($pathinfo['dirname']);
+
+		if (is_resource($dirContent)) {
+			while (($file = readdir($dirContent)) !== false) {
+				if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
+					if (preg_match("/" . $pathinfo['filename'] . ".(.*).shareKey/", $file)) {
+						$result[] = $pathinfo['dirname'] . '/' . $file;
+					}
+				}
+			}
+			closedir($dirContent);
+		}
+
+		return $result;
+	}
+
+	/**
 	 * @brief remember from which file the tmp file (getLocalFile() call) was created
 	 * @param string $tmpFile path of tmp file
 	 * @param string $originalFile path of the original file relative to data/

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