aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-03-27 16:43:34 +0100
committerRobin Appelman <icewind@owncloud.com>2014-03-28 15:15:56 +0100
commitf331d5f9d4a4609370bf6a5593e0720ba7c77c04 (patch)
treefdbcd0a1718713eed58a12cf48366c2aefb2bc0a /lib
parent1f6259d9c284fb917210fc438c9ff30a4549aed0 (diff)
downloadnextcloud-server-f331d5f9d4a4609370bf6a5593e0720ba7c77c04.tar.gz
nextcloud-server-f331d5f9d4a4609370bf6a5593e0720ba7c77c04.zip
Give storages the option to implement the getById behaviour for View->getPath
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/cache/cache.php16
-rw-r--r--lib/private/files/view.php19
2 files changed, 29 insertions, 6 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index abc11e76470..42fee4f336d 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -597,6 +597,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 f06c2fcd66c..90b0da09c37 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1129,15 +1129,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;