diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-08-17 12:53:24 +0200 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2015-11-04 09:27:29 +0100 |
commit | 4719305e3b99d53c72a341c5b6cbfee6bf984fb7 (patch) | |
tree | 550c78e3fd6de1e856e80338a398db7fd9e0a954 /lib/private/encryption | |
parent | 7fe047425fa0dc29069ea0c783464e16ed19ae98 (diff) | |
download | nextcloud-server-4719305e3b99d53c72a341c5b6cbfee6bf984fb7.tar.gz nextcloud-server-4719305e3b99d53c72a341c5b6cbfee6bf984fb7.zip |
cache result from parent folders
Diffstat (limited to 'lib/private/encryption')
-rw-r--r-- | lib/private/encryption/file.php | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/private/encryption/file.php b/lib/private/encryption/file.php index 5a7357b9e28..6d261f46d0f 100644 --- a/lib/private/encryption/file.php +++ b/lib/private/encryption/file.php @@ -27,6 +27,13 @@ class File implements \OCP\Encryption\IFile { /** @var Util */ protected $util; + /** + * cache results of already checked folders + * + * @var array + */ + protected $cache; + public function __construct(Util $util) { $this->util = $util; } @@ -53,10 +60,24 @@ class File implements \OCP\Encryption\IFile { $ownerPath = substr($ownerPath, strlen('/files')); $ownerPath = $this->util->stripPartialFileExtension($ownerPath); + + // first get the shares for the parent and cache the result so that we don't + // need to check all parents for every file + $parent = dirname($ownerPath); + if (isset($this->cache[$parent])) { + $resultForParents = $this->cache[$parent]; + } else { + $resultForParents = \OCP\Share::getUsersSharingFile($parent, $owner); + $this->cache[$parent] = $resultForParents; + } + $userIds = \array_merge($userIds, $resultForParents['users']); + $public = $resultForParents['public'] || $resultForParents['remote']; + + // Find out who, if anyone, is sharing the file - $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner); - $userIds = \array_merge($userIds, $result['users']); - $public = $result['public'] || $result['remote']; + $resultForFile = \OCP\Share::getUsersSharingFile($ownerPath, $owner, false, false, false); + $userIds = \array_merge($userIds, $resultForFile['users']); + $public = $resultForFile['public'] || $resultForFile['remote'] || $public; // check if it is a group mount if (\OCP\App::isEnabled("files_external")) { |