diff options
author | Robin Appelman <robin@icewind.nl> | 2017-08-22 15:44:52 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-10-27 14:35:34 +0200 |
commit | 3f0cb130421b4626041d3d60f0bde9e5da9d5dcc (patch) | |
tree | a57e37c46c3e3c8bd125f75929402af7d68c325b /lib/private/Files/Config/UserMountCache.php | |
parent | 7a4c0c668baef6fe86b6131444cab122a4b3b374 (diff) | |
download | nextcloud-server-3f0cb130421b4626041d3d60f0bde9e5da9d5dcc.tar.gz nextcloud-server-3f0cb130421b4626041d3d60f0bde9e5da9d5dcc.zip |
Allow getting the filepath when getting cached mounts by fileid
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Config/UserMountCache.php')
-rw-r--r-- | lib/private/Files/Config/UserMountCache.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 9466aaf6c89..62befbf9e85 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -27,6 +27,7 @@ namespace OC\Files\Config; use OC\DB\QueryBuilder\Literal; use OCA\Files_Sharing\SharedMount; use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\Files\Config\ICachedMountFileInfo; use OCP\Files\Config\ICachedMountInfo; use OCP\Files\Config\IUserMountCache; use OCP\Files\Mount\IMountPoint; @@ -282,7 +283,7 @@ class UserMountCache implements IUserMountCache { /** * @param int $fileId * @param string|null $user optionally restrict the results to a single user - * @return ICachedMountInfo[] + * @return ICachedMountFileInfo[] * @since 9.0.0 */ public function getMountsForFileId($fileId, $user = null) { @@ -294,7 +295,7 @@ class UserMountCache implements IUserMountCache { $mountsForStorage = $this->getMountsForStorageId($storageId, $user); // filter mounts that are from the same storage but a different directory - return array_filter($mountsForStorage, function (ICachedMountInfo $mount) use ($internalPath, $fileId) { + $filteredMounts = array_filter($mountsForStorage, function (ICachedMountInfo $mount) use ($internalPath, $fileId) { if ($fileId === $mount->getRootId()) { return true; } @@ -302,6 +303,18 @@ class UserMountCache implements IUserMountCache { return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/'; }); + + return array_map(function (ICachedMountInfo $mount) use ($internalPath) { + return new CachedMountFileInfo( + $mount->getUser(), + $mount->getStorageId(), + $mount->getRootId(), + $mount->getMountPoint(), + $mount->getMountId(), + $mount->getRootInternalPath(), + $internalPath + ); + }, $filteredMounts); } /** |