diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-11-18 11:33:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-18 11:33:33 +0100 |
commit | ccdf387041158dbacfcb8f8123a78cc86ce95bf1 (patch) | |
tree | a6fa32ca0432c04ced647ee9735888db42700515 /apps | |
parent | 00fffae47f4563e6b6e2f5efe632d8341cf1425c (diff) | |
parent | 5acbdf1e36ba707d50b0c10b69c8001b8efead1d (diff) | |
download | nextcloud-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')
-rw-r--r-- | apps/files_sharing/lib/Cache.php | 24 | ||||
-rw-r--r-- | apps/files_sharing/lib/MountProvider.php | 3 | ||||
-rw-r--r-- | apps/files_sharing/lib/SharedStorage.php | 32 |
3 files changed, 36 insertions, 23 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index 21f3ff622f9..49765a7aab5 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -43,38 +43,32 @@ class Cache extends CacheJail { private $storage; /** - * @var IStorage - */ - private $sourceStorage; - - /** * @var ICacheEntry */ private $sourceRootInfo; - /** - * @var \OCP\Files\Cache\ICache - */ - private $sourceCache; - private $rootUnchanged = true; /** * @param \OCA\Files_Sharing\SharedStorage $storage - * @param IStorage $sourceStorage * @param ICacheEntry $sourceRootInfo */ - public function __construct($storage, IStorage $sourceStorage, ICacheEntry $sourceRootInfo) { + public function __construct($storage, ICacheEntry $sourceRootInfo) { $this->storage = $storage; - $this->sourceStorage = $sourceStorage; $this->sourceRootInfo = $sourceRootInfo; - $this->sourceCache = $sourceStorage->getCache(); parent::__construct( - $this->sourceCache, + null, $this->sourceRootInfo->getPath() ); } + public function getCache() { + if (is_null($this->cache)) { + $this->cache = $this->storage->getSourceStorage()->getCache(); + } + return $this->cache; + } + public function getNumericStorageId() { if (isset($this->numericId)) { return $this->numericId; 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..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; + } } |