diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-03 12:30:38 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-03 12:30:38 +0100 |
commit | e62b6c1617886b2cdd7553ea9b119c431e4eb363 (patch) | |
tree | e592df08501a2274e863114d3356dd7465b7df25 /apps | |
parent | 3a391e4cc9ead18c1e1381966edad4683a92214b (diff) | |
parent | 9dd11091d4f9a970a3e76d77e772b5905666ed30 (diff) | |
download | nextcloud-server-e62b6c1617886b2cdd7553ea9b119c431e4eb363.tar.gz nextcloud-server-e62b6c1617886b2cdd7553ea9b119c431e4eb363.zip |
Merge pull request #20729 from owncloud/issue_20599
Add different storage status error codes managed by StoragedNotAvailableExc…
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/controller/storagescontroller.php | 8 | ||||
-rw-r--r-- | apps/files_external/lib/config.php | 12 | ||||
-rw-r--r-- | apps/files_external/service/storagesservice.php | 3 |
3 files changed, 10 insertions, 13 deletions
diff --git a/apps/files_external/controller/storagescontroller.php b/apps/files_external/controller/storagescontroller.php index c66bd902d8d..7712f9769c9 100644 --- a/apps/files_external/controller/storagescontroller.php +++ b/apps/files_external/controller/storagescontroller.php @@ -238,18 +238,18 @@ abstract class StoragesController extends Controller { ); } catch (InsufficientDataForMeaningfulAnswerException $e) { $storage->setStatus( - \OC_Mount_Config::STATUS_INDETERMINATE, + StorageNotAvailableException::STATUS_INDETERMINATE, $this->l10n->t('Insufficient data: %s', [$e->getMessage()]) ); } catch (StorageNotAvailableException $e) { $storage->setStatus( - \OC_Mount_Config::STATUS_ERROR, - $e->getMessage() + $e->getCode(), + $this->l10n->t('%s', [$e->getMessage()]) ); } catch (\Exception $e) { // FIXME: convert storage exceptions to StorageNotAvailableException $storage->setStatus( - \OC_Mount_Config::STATUS_ERROR, + StorageNotAvailableException::STATUS_ERROR, get_class($e).': '.$e->getMessage() ); } diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 1e96fac8145..7a869847a63 100644 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -36,6 +36,7 @@ use \OCA\Files_External\Appinfo\Application; use \OCA\Files_External\Lib\Backend\LegacyBackend; use \OCA\Files_External\Lib\StorageConfig; use \OCA\Files_External\Lib\Backend\Backend; +use \OCP\Files\StorageNotAvailableException; /** * Class to configure mount.json globally and for users @@ -48,11 +49,6 @@ class OC_Mount_Config { const MOUNT_TYPE_USER = 'user'; const MOUNT_TYPE_PERSONAL = 'personal'; - // getBackendStatus return types - const STATUS_SUCCESS = 0; - const STATUS_ERROR = 1; - const STATUS_INDETERMINATE = 2; - // whether to skip backend test (for unit tests, as this static class is not mockable) public static $skipTest = false; @@ -219,7 +215,7 @@ class OC_Mount_Config { */ public static function getBackendStatus($class, $options, $isPersonal) { if (self::$skipTest) { - return self::STATUS_SUCCESS; + return StorageNotAvailableException::STATUS_SUCCESS; } foreach ($options as &$option) { $option = self::setUserVars(OCP\User::getUser(), $option); @@ -233,7 +229,7 @@ class OC_Mount_Config { $result = $storage->test($isPersonal); $storage->setAvailability($result); if ($result) { - return self::STATUS_SUCCESS; + return StorageNotAvailableException::STATUS_SUCCESS; } } catch (\Exception $e) { $storage->setAvailability(false); @@ -244,7 +240,7 @@ class OC_Mount_Config { throw $exception; } } - return self::STATUS_ERROR; + return StorageNotAvailableException::STATUS_ERROR; } /** diff --git a/apps/files_external/service/storagesservice.php b/apps/files_external/service/storagesservice.php index 3446ed0dab3..c847930ba2d 100644 --- a/apps/files_external/service/storagesservice.php +++ b/apps/files_external/service/storagesservice.php @@ -31,6 +31,7 @@ use \OCA\Files_external\NotFoundException; use \OCA\Files_External\Service\BackendService; use \OCA\Files_External\Lib\Backend\Backend; use \OCA\Files_External\Lib\Auth\AuthMechanism; +use \OCP\Files\StorageNotAvailableException; /** * Service class to manage external storages @@ -411,7 +412,7 @@ abstract class StoragesService { $this->triggerHooks($newStorage, Filesystem::signal_create_mount); - $newStorage->setStatus(\OC_Mount_Config::STATUS_SUCCESS); + $newStorage->setStatus(StorageNotAvailableException::STATUS_SUCCESS); return $newStorage; } |