diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-01-26 23:59:29 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-01-27 00:13:50 +0100 |
commit | 9e2a066c7bf04dfcc3e2dcc539e1b33053ba70ed (patch) | |
tree | 0429b7b730a1f2973c98f166b2aee02dc93be384 /lib/files/cache/cache.php | |
parent | 8c42e2de8c8be9bd5914794dbf01a10f575788d1 (diff) | |
download | nextcloud-server-9e2a066c7bf04dfcc3e2dcc539e1b33053ba70ed.tar.gz nextcloud-server-9e2a066c7bf04dfcc3e2dcc539e1b33053ba70ed.zip |
Cache: add function to get storage id and internal path of a file by id
Diffstat (limited to 'lib/files/cache/cache.php')
-rw-r--r-- | lib/files/cache/cache.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php index 7f6d191fee4..69cbaea8516 100644 --- a/lib/files/cache/cache.php +++ b/lib/files/cache/cache.php @@ -494,4 +494,28 @@ class Cache { return false; } } + + /** + * get the storage id of the storage for a file and the internal path of the file + * + * @return array, first element holding the storage id, second the path + */ + static public function getById($id) { + $query = \OC_DB::prepare('SELECT `storage`, `path` FROM `*PREFIX*filecache` WHERE `fileid` = ?'); + $result = $query->execute(array($id)); + if ($row = $result->fetchRow()) { + $numericId = $row['storage']; + $path = $row['path']; + } else { + return null; + } + + $query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*storages` WHERE `numeric_id` = ?'); + $result = $query->execute(array($numericId)); + if ($row = $result->fetchRow()) { + return array($row['id'], $path); + } else { + return null; + } + } } |