diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-15 12:15:05 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-15 12:15:05 +0100 |
commit | 0f6ea9fd292a26572f28440ee71bc1a4453906b9 (patch) | |
tree | 4fff82916a0d6d35b99018d516409ec3032bd37e /apps/files_sharing | |
parent | e9eeb3607fe0ba15413c1c22b1120fc53aaed6dc (diff) | |
parent | a8db587b1f036bba917288372405d8d830faee54 (diff) | |
download | nextcloud-server-0f6ea9fd292a26572f28440ee71bc1a4453906b9.tar.gz nextcloud-server-0f6ea9fd292a26572f28440ee71bc1a4453906b9.zip |
Merge pull request #23039 from owncloud/invalid-share-storage
dont break when there is an invalid share
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/lib/sharedstorage.php | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 6998f94698e..8f4888d20e2 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -31,6 +31,7 @@ namespace OC\Files\Storage; use OC\Files\Filesystem; +use OC\Files\Cache\FailedCache; use OCA\Files_Sharing\ISharedStorage; use OCP\Constants; use OCP\Files\Cache\ICacheEntry; @@ -67,10 +68,16 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { */ private $sourceStorage; + /** + * @var \OCP\ILogger + */ + private $logger; + public function __construct($arguments) { $this->share = $arguments['share']; $this->ownerView = $arguments['ownerView']; $this->user = $arguments['user']; + $this->logger = \OC::$server->getLogger(); } private function init() { @@ -78,15 +85,19 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { return; } $this->initialized = true; - Filesystem::initMountPoints($this->share['uid_owner']); - $sourcePath = $this->ownerView->getPath($this->share['file_source']); - list($this->sourceStorage, $sourceInternalPath) = $this->ownerView->resolvePath($sourcePath); - $this->sourceRootInfo = $this->sourceStorage->getCache()->get($sourceInternalPath); + try { + Filesystem::initMountPoints($this->share['uid_owner']); + $sourcePath = $this->ownerView->getPath($this->share['file_source']); + list($this->sourceStorage, $sourceInternalPath) = $this->ownerView->resolvePath($sourcePath); + $this->sourceRootInfo = $this->sourceStorage->getCache()->get($sourceInternalPath); + } catch (\Exception $e) { + $this->logger->logException($e); + } } private function isValid() { $this->init(); - return ($this->sourceRootInfo->getPermissions() & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE; + return $this->sourceRootInfo && ($this->sourceRootInfo->getPermissions() & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE; } /** @@ -568,6 +579,9 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { public function getCache($path = '', $storage = null) { $this->init(); + if (is_null($this->sourceStorage)) { + return new FailedCache(false); + } if (!$storage) { $storage = $this; } |