summaryrefslogtreecommitdiffstats
path: root/apps/files_external/controller
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@owncloud.com>2015-08-12 19:51:09 +0100
committerRobin McCorkell <rmccorkell@owncloud.com>2015-08-19 10:08:23 +0100
commitb6eb952ac61326a15108820b0dd0a1712f00dfdb (patch)
tree73457afc836bfac5a9af9364210e38b5667eea87 /apps/files_external/controller
parentc592e24c871f0f6a8d688c5c93e769b1505e4b6d (diff)
downloadnextcloud-server-b6eb952ac61326a15108820b0dd0a1712f00dfdb.tar.gz
nextcloud-server-b6eb952ac61326a15108820b0dd0a1712f00dfdb.zip
Propagate auth mechanism/backend failures to filesystem layer
Failure to prepare the storage during backend or auth mechanism manipulation will throw an InsufficientDataForMeaningfulAnswerException, which is propagated to StorageNotAvailableException in the filesystem layer via the FailedStorage helper class. When a storage is unavailable not due to failure, but due to insufficient data being available, a special 'indeterminate' status is returned to the configuration UI.
Diffstat (limited to 'apps/files_external/controller')
-rw-r--r--apps/files_external/controller/storagescontroller.php38
1 files changed, 23 insertions, 15 deletions
diff --git a/apps/files_external/controller/storagescontroller.php b/apps/files_external/controller/storagescontroller.php
index f1d1625bdc6..3d91af8bd8f 100644
--- a/apps/files_external/controller/storagescontroller.php
+++ b/apps/files_external/controller/storagescontroller.php
@@ -34,6 +34,8 @@ use \OCA\Files_external\NotFoundException;
use \OCA\Files_external\Lib\StorageConfig;
use \OCA\Files_External\Lib\Backend\Backend;
use \OCA\Files_External\Lib\Auth\AuthMechanism;
+use \OCP\Files\StorageNotAvailableException;
+use \OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
/**
* Base class for storages controllers
@@ -182,21 +184,27 @@ abstract class StoragesController extends Controller {
* @param StorageConfig $storage storage configuration
*/
protected function updateStorageStatus(StorageConfig &$storage) {
- /** @var AuthMechanism */
- $authMechanism = $storage->getAuthMechanism();
- $authMechanism->manipulateStorageConfig($storage);
- /** @var Backend */
- $backend = $storage->getBackend();
- $backend->manipulateStorageConfig($storage);
-
- // update status (can be time-consuming)
- $storage->setStatus(
- \OC_Mount_Config::getBackendStatus(
- $storage->getBackend()->getStorageClass(),
- $storage->getBackendOptions(),
- false
- )
- );
+ try {
+ /** @var AuthMechanism */
+ $authMechanism = $storage->getAuthMechanism();
+ $authMechanism->manipulateStorageConfig($storage);
+ /** @var Backend */
+ $backend = $storage->getBackend();
+ $backend->manipulateStorageConfig($storage);
+
+ // update status (can be time-consuming)
+ $storage->setStatus(
+ \OC_Mount_Config::getBackendStatus(
+ $backend->getStorageClass(),
+ $storage->getBackendOptions(),
+ false
+ )
+ );
+ } catch (InsufficientDataForMeaningfulAnswerException $e) {
+ $storage->setStatus(\OC_Mount_Config::STATUS_INDETERMINATE);
+ } catch (StorageNotAvailableException $e) {
+ $storage->setStatus(\OC_Mount_Config::STATUS_ERROR);
+ }
}
/**