[Pkg-owncloud-commits] [owncloud] 33/55: Give storages the option to implement the getById behaviour for View->getPath
David Prévot
taffit at moszumanska.debian.org
Wed Apr 23 19:52:00 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v5.0.16RC1
in repository owncloud.
commit d3926b8d5e43a4fc17c4e46eb142f70b6a939739
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/files/cache/cache.php | 17 +++++++++++++++++
lib/files/view.php | 16 +++++++++++-----
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index c8fa27e..d62a904 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -662,6 +662,23 @@ 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/files/view.php b/lib/files/view.php
index 19dea87..3d5d457 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -1059,15 +1059,21 @@ class View {
* @return string
*/
public function getPath($id) {
- list($storage, $internalPath) = Cache\Cache::getById($id);
- $mounts = Mount::findByStorageId($storage);
+ $mounts = Mount::findIn($this->fakeRoot);
+ $mounts[] = Mount::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
*/
- $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