Storage 503 message improvements

"Storage not available" is now "Storage temporarily not available".
Exceptions are now logged in DEBUG level, not FATAL.
This commit is contained in:
Vincent Petry 2016-09-19 12:17:06 +02:00 committed by Morris Jobke
parent 729c06548f
commit 44cf67accd
No known key found for this signature in database
GPG key ID: 9CE5ED29E7FCD38A
6 changed files with 14 additions and 11 deletions

View file

@ -32,7 +32,7 @@ use Sabre\DAV\Exception;
use Sabre\HTTP\Response; use Sabre\HTTP\Response;
class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin { class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
protected $nonFatalExceptions = array( protected $nonFatalExceptions = [
'Sabre\DAV\Exception\NotAuthenticated' => true, 'Sabre\DAV\Exception\NotAuthenticated' => true,
// If tokenauth can throw this exception (which is basically as // If tokenauth can throw this exception (which is basically as
// NotAuthenticated. So not fatal. // NotAuthenticated. So not fatal.
@ -47,7 +47,10 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
// forbidden can be expected when trying to upload to // forbidden can be expected when trying to upload to
// read-only folders for example // read-only folders for example
'Sabre\DAV\Exception\Forbidden' => true, 'Sabre\DAV\Exception\Forbidden' => true,
); // Happens when an external storage or federated share is temporarily
// not available
'Sabre\DAV\Exception\StorageNotAvailableException' => true,
];
/** @var string */ /** @var string */
private $appName; private $appName;

View file

@ -159,7 +159,7 @@ class ObjectTree extends \Sabre\DAV\Tree {
try { try {
$info = $this->fileView->getFileInfo($path); $info = $this->fileView->getFileInfo($path);
} catch (StorageNotAvailableException $e) { } catch (StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage not available'); throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage is temporarily not available');
} catch (StorageInvalidException $e) { } catch (StorageInvalidException $e) {
throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid'); throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid');
} catch (LockedException $e) { } catch (LockedException $e) {

View file

@ -79,12 +79,12 @@ try {
OCP\JSON::success(array('data' => $data)); OCP\JSON::success(array('data' => $data));
} catch (\OCP\Files\StorageNotAvailableException $e) { } catch (\OCP\Files\StorageNotAvailableException $e) {
\OCP\Util::logException('files', $e); \OCP\Util::logException('files', $e);
OCP\JSON::error(array( OCP\JSON::error([
'data' => array( 'data' => [
'exception' => '\OCP\Files\StorageNotAvailableException', 'exception' => '\OCP\Files\StorageNotAvailableException',
'message' => $l->t('Storage not available') 'message' => $l->t('Storage is temporarily not available')
) ]
)); ]);
} catch (\OCP\Files\StorageInvalidException $e) { } catch (\OCP\Files\StorageInvalidException $e) {
\OCP\Util::logException('files', $e); \OCP\Util::logException('files', $e);
OCP\JSON::error(array( OCP\JSON::error(array(

View file

@ -1602,7 +1602,7 @@
this.changeDirectory('/'); this.changeDirectory('/');
// TODO: read error message from exception // TODO: read error message from exception
OC.Notification.showTemporary( OC.Notification.showTemporary(
t('files', 'Storage not available') t('files', 'Storage is temporarily not available')
); );
} }
return false; return false;

View file

@ -2668,7 +2668,7 @@ describe('OCA.Files.FileList tests', function() {
}); });
it('redirects to root folder and shows notification in case of storage not available', function () { it('redirects to root folder and shows notification in case of storage not available', function () {
expect(notificationStub.notCalled).toEqual(true); expect(notificationStub.notCalled).toEqual(true);
deferredList.reject(503, 'Storage not available'); deferredList.reject(503, 'Storage is temporarily not available');
expect(fileList.getCurrentDirectory()).toEqual('/'); expect(fileList.getCurrentDirectory()).toEqual('/');
expect(getFolderContentsStub.calledTwice).toEqual(true); expect(getFolderContentsStub.calledTwice).toEqual(true);

View file

@ -58,7 +58,7 @@ class StorageNotAvailableException extends HintException {
*/ */
public function __construct($message = '', $code = self::STATUS_ERROR, \Exception $previous = null) { public function __construct($message = '', $code = self::STATUS_ERROR, \Exception $previous = null) {
$l = \OC::$server->getL10N('core'); $l = \OC::$server->getL10N('core');
parent::__construct($message, $l->t('Storage not available'), $code, $previous); parent::__construct($message, $l->t('Storage is temporarily not available'), $code, $previous);
} }
/** /**