aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/SharedStorage.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-11-18 11:33:33 +0100
committerGitHub <noreply@github.com>2016-11-18 11:33:33 +0100
commitccdf387041158dbacfcb8f8123a78cc86ce95bf1 (patch)
treea6fa32ca0432c04ced647ee9735888db42700515 /apps/files_sharing/lib/SharedStorage.php
parent00fffae47f4563e6b6e2f5efe632d8341cf1425c (diff)
parent5acbdf1e36ba707d50b0c10b69c8001b8efead1d (diff)
downloadnextcloud-server-ccdf387041158dbacfcb8f8123a78cc86ce95bf1.tar.gz
nextcloud-server-ccdf387041158dbacfcb8f8123a78cc86ce95bf1.zip
Merge pull request #2184 from nextcloud/share-join-cache
Get the share root info directly when querying for shares
Diffstat (limited to 'apps/files_sharing/lib/SharedStorage.php')
-rw-r--r--apps/files_sharing/lib/SharedStorage.php32
1 files changed, 24 insertions, 8 deletions
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index 7002d388d93..5b4aa061800 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -71,6 +71,8 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
*/
private $logger;
+ private $options;
+
public function __construct($arguments) {
$this->ownerView = $arguments['ownerView'];
$this->logger = \OC::$server->getLogger();
@@ -86,6 +88,20 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
]);
}
+ /**
+ * @return ICacheEntry
+ */
+ private function getSourceRootInfo() {
+ if (is_null($this->sourceRootInfo)) {
+ if (is_null($this->superShare->getNodeCacheEntry())) {
+ $this->sourceRootInfo = $this->getWrapperStorage()->getCache()->get($this->rootPath);
+ } else {
+ $this->sourceRootInfo = $this->superShare->getNodeCacheEntry();
+ }
+ }
+ return $this->sourceRootInfo;
+ }
+
private function init() {
if ($this->initialized) {
return;
@@ -95,7 +111,6 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
Filesystem::initMountPoints($this->superShare->getShareOwner());
$sourcePath = $this->ownerView->getPath($this->superShare->getNodeId());
list($this->storage, $this->rootPath) = $this->ownerView->resolvePath($sourcePath);
- $this->sourceRootInfo = $this->storage->getCache()->get($this->rootPath);
} catch (NotFoundException $e) {
$this->storage = new FailedStorage(['exception' => $e]);
$this->rootPath = '';
@@ -110,6 +125,9 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
* @inheritdoc
*/
public function instanceOfStorage($class) {
+ if ($class === '\OC\Files\Storage\Common') {
+ return true;
+ }
if (in_array($class, ['\OC\Files\Storage\Home', '\OC\Files\ObjectStore\HomeObjectStoreStorage'])) {
return false;
}
@@ -124,8 +142,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
}
private function isValid() {
- $this->init();
- return $this->sourceRootInfo && ($this->sourceRootInfo->getPermissions() & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE;
+ return $this->getSourceRootInfo() && ($this->getSourceRootInfo()->getPermissions() & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE;
}
/**
@@ -314,14 +331,10 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
if ($this->cache) {
return $this->cache;
}
- $this->init();
- if (is_null($this->storage) || $this->storage instanceof FailedStorage) {
- return new FailedCache(false);
- }
if (!$storage) {
$storage = $this;
}
- $this->cache = new \OCA\Files_Sharing\Cache($storage, $this->storage, $this->sourceRootInfo);
+ $this->cache = new \OCA\Files_Sharing\Cache($storage, $this->getSourceRootInfo(), $this->superShare);
return $this->cache;
}
@@ -449,4 +462,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
return parent::file_put_contents($path, $data);
}
+ public function setMountOptions(array $options) {
+ $this->mountOptions = $options;
+ }
}