summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2016-11-17 14:18:47 +0100
committerRobin Appelman <robin@icewind.nl>2016-11-17 18:48:38 +0100
commit2f03fcab4af43de3ee5e0b25aa7aa18ca8f4c4db (patch)
tree9c858a653a582197d02af31d182e89e3df971d53 /apps
parent065753f0ae39cfee229cefb612ca8243b9bae6ca (diff)
downloadnextcloud-server-2f03fcab4af43de3ee5e0b25aa7aa18ca8f4c4db.tar.gz
nextcloud-server-2f03fcab4af43de3ee5e0b25aa7aa18ca8f4c4db.zip
let the share backend get the node cacheentry to save queries
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/MountProvider.php3
-rw-r--r--apps/files_sharing/lib/SharedStorage.php32
2 files changed, 27 insertions, 8 deletions
diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php
index 1ee6f2b35f6..40d2fb27535 100644
--- a/apps/files_sharing/lib/MountProvider.php
+++ b/apps/files_sharing/lib/MountProvider.php
@@ -172,6 +172,9 @@ class MountProvider implements IMountProvider {
$share->setTarget($superShare->getTarget());
$this->shareManager->moveShare($share, $user->getUID());
}
+ if (!is_null($share->getNodeCacheEntry())) {
+ $superShare->setNodeCacheEntry($share->getNodeCacheEntry());
+ }
}
$superShare->setPermissions($permissions);
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index 7002d388d93..86209f6f744 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->storage->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;
+ }
}