aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-15 12:15:05 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-15 12:15:05 +0100
commit0f6ea9fd292a26572f28440ee71bc1a4453906b9 (patch)
tree4fff82916a0d6d35b99018d516409ec3032bd37e
parente9eeb3607fe0ba15413c1c22b1120fc53aaed6dc (diff)
parenta8db587b1f036bba917288372405d8d830faee54 (diff)
downloadnextcloud-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
-rw-r--r--apps/files_external/lib/config/configadapter.php2
-rw-r--r--apps/files_sharing/lib/sharedstorage.php24
-rw-r--r--lib/private/files/cache/failedcache.php (renamed from apps/files_external/lib/failedcache.php)17
-rw-r--r--lib/private/files/storage/failedstorage.php (renamed from apps/files_external/lib/failedstorage.php)4
4 files changed, 36 insertions, 11 deletions
diff --git a/apps/files_external/lib/config/configadapter.php b/apps/files_external/lib/config/configadapter.php
index d85e0f45631..a19a111d3d9 100644
--- a/apps/files_external/lib/config/configadapter.php
+++ b/apps/files_external/lib/config/configadapter.php
@@ -34,7 +34,7 @@ use OCP\IUser;
use OCA\Files_external\Service\UserStoragesService;
use OCA\Files_External\Service\UserGlobalStoragesService;
use OCA\Files_External\Lib\StorageConfig;
-use OCA\Files_External\Lib\FailedStorage;
+use OC\Files\Storage\FailedStorage;
use OCP\Files\StorageNotAvailableException;
/**
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;
}
diff --git a/apps/files_external/lib/failedcache.php b/lib/private/files/cache/failedcache.php
index 0f59495e595..0386ba3ca32 100644
--- a/apps/files_external/lib/failedcache.php
+++ b/lib/private/files/cache/failedcache.php
@@ -19,9 +19,8 @@
*
*/
-namespace OCA\Files_External\Lib;
+namespace OC\Files\Cache;
-use OC\Files\Cache\CacheEntry;
use OCP\Constants;
use OCP\Files\Cache\ICache;
@@ -29,6 +28,18 @@ use OCP\Files\Cache\ICache;
* Storage placeholder to represent a missing precondition, storage unavailable
*/
class FailedCache implements ICache {
+ /** @var bool whether to show the failed storage in the ui */
+ private $visible;
+
+ /**
+ * FailedCache constructor.
+ *
+ * @param bool $visible
+ */
+ public function __construct($visible = true) {
+ $this->visible = $visible;
+ }
+
public function getNumericStorageId() {
return -1;
@@ -41,7 +52,7 @@ class FailedCache implements ICache {
'size' => 0,
'mimetype' => 'httpd/unix-directory',
'mimepart' => 'httpd',
- 'permissions' => Constants::PERMISSION_READ,
+ 'permissions' => $this->visible ? Constants::PERMISSION_READ : 0,
'mtime' => time()
]);
} else {
diff --git a/apps/files_external/lib/failedstorage.php b/lib/private/files/storage/failedstorage.php
index 20cf43d74b2..df7f76856d5 100644
--- a/apps/files_external/lib/failedstorage.php
+++ b/lib/private/files/storage/failedstorage.php
@@ -20,10 +20,10 @@
*
*/
-namespace OCA\Files_External\Lib;
+namespace OC\Files\Storage;
+use OC\Files\Cache\FailedCache;
use \OCP\Lock\ILockingProvider;
-use \OC\Files\Storage\Common;
use \OCP\Files\StorageNotAvailableException;
/**