aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-04-01 21:59:09 +0200
committerVincent Petry <pvince81@owncloud.com>2014-04-01 21:59:09 +0200
commitd811026ec9008331049726d6b26a76913df95f82 (patch)
tree5462b40a4130b1eac40d53dfede17bb7313a36fd /lib
parentbd2cf6ee29da41f8414efb356b4d894854fcf976 (diff)
parent0c2585f3ac9dbf82bf45023963dfecc66c515b78 (diff)
downloadnextcloud-server-d811026ec9008331049726d6b26a76913df95f82.tar.gz
nextcloud-server-d811026ec9008331049726d6b26a76913df95f82.zip
Merge pull request #7935 from owncloud/getpath-shared
Make getPath work for shared files
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/cache/cache.php18
-rw-r--r--lib/private/files/view.php19
2 files changed, 31 insertions, 6 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index abc11e76470..1c9de56f8c5 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -594,7 +594,25 @@ class Cache {
}
/**
+ * get the path of a file on this storage by it's id
+ *
+ * @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
+ * unlike getPathById this does not limit the search to files on this storage and
+ * instead does a global search in the cache table
*
* @param int $id
* @return array, first element holding the storage id, second the path
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;