[Pkg-owncloud-commits] [owncloud] 91/134: Give storages the option to implement the getById behaviour for View->getPath

David Prévot taffit at moszumanska.debian.org
Fri Apr 18 21:44:04 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 2150cac956515603d34efe3deafb1ce33d0b3294
Author: Robin Appelman <icewind at owncloud.com>
Date:   Thu Mar 27 16:43:34 2014 +0100

    Give storages the option to implement the getById behaviour for View->getPath
---
 lib/private/files/cache/cache.php | 16 ++++++++++++++++
 lib/private/files/view.php        | 19 +++++++++++++------
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 1e7936c..03616cb 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -583,6 +583,22 @@ class Cache {
 	 * get the storage id of the storage for a file and the internal path of the file
 	 *
 	 * @param int $id
+	 * @return string | null
+	 */
+	public function getPathById($id) {
+		$sql = 'SELECT `path` FROM `*PREFIX*filecache` WHERE `fileid` = ? AND `storage` = ?';
+		$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
+		if ($row = $result->fetchRow()) {
+			return $row['path'];
+		} else {
+			return null;
+		}
+	}
+
+	/**
+	 * get the storage id of the storage for a file and the internal path of the file
+	 *
+	 * @param int $id
 	 * @return array, first element holding the storage id, second the path
 	 */
 	static public function getById($id) {
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 3b89cd0..70affde 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1090,15 +1090,22 @@ class View {
 	 * @return string
 	 */
 	public function getPath($id) {
-		list($storage, $internalPath) = Cache\Cache::getById($id);
-		$mounts = Filesystem::getMountByStorageId($storage);
+		$manager = Filesystem::getMountManager();
+		$mounts = $manager->findIn($this->fakeRoot);
+		$mounts[] = $manager->find($this->fakeRoot);
+		// reverse the array so we start with the storage this view is in
+		// which is the most likely to contain the file we're looking for
+		$mounts = array_reverse($mounts);
 		foreach ($mounts as $mount) {
 			/**
-			 * @var \OC\Files\Mount $mount
+			 * @var \OC\Files\Mount\Mount $mount
 			 */
-			$fullPath = $mount->getMountPoint() . $internalPath;
-			if (!is_null($path = $this->getRelativePath($fullPath))) {
-				return $path;
+			$cache = $mount->getStorage()->getCache();
+			if ($internalPath = $cache->getPathById($id)) {
+				$fullPath = $mount->getMountPoint() . $internalPath;
+				if (!is_null($path = $this->getRelativePath($fullPath))) {
+					return $path;
+				}
 			}
 		}
 		return null;

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