summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2016-06-27 21:34:28 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-06-27 21:34:28 +0200
commit332b38fd921f3ce1181a4c1308565b323dd50467 (patch)
tree0298a8dfb2aa254f5e68768975503428a03771d9
parentf107be3d295d5a7cae7bc43559396b56030fc57c (diff)
downloadnextcloud-server-332b38fd921f3ce1181a4c1308565b323dd50467.tar.gz
nextcloud-server-332b38fd921f3ce1181a4c1308565b323dd50467.zip
handle unavailable fed shares while testing for availability (#25277)
* More explicit http status codes * handle unavailable fed shares while testing for availability
-rw-r--r--apps/files_sharing/lib/External/Storage.php19
-rw-r--r--lib/private/Files/Storage/DAV.php6
2 files changed, 20 insertions, 5 deletions
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php
index 29b9c7b563c..bc8d898f8ef 100644
--- a/apps/files_sharing/lib/External/Storage.php
+++ b/apps/files_sharing/lib/External/Storage.php
@@ -32,6 +32,7 @@ use OC\Files\Storage\DAV;
use OC\ForbiddenException;
use OCA\FederatedFileSharing\DiscoveryManager;
use OCA\Files_Sharing\ISharedStorage;
+use OCP\AppFramework\Http;
use OCP\Files\NotFoundException;
use OCP\Files\StorageInvalidException;
use OCP\Files\StorageNotAvailableException;
@@ -181,6 +182,20 @@ class Storage extends DAV implements ISharedStorage {
}
}
+ public function test() {
+ try {
+ parent::test();
+ } catch (StorageInvalidException $e) {
+ // check if it needs to be removed
+ $this->checkStorageAvailability();
+ throw $e;
+ } catch (StorageNotAvailableException $e) {
+ // check if it needs to be removed or just temp unavailable
+ $this->checkStorageAvailability();
+ throw $e;
+ }
+ }
+
/**
* Check whether this storage is permanently or temporarily
* unavailable
@@ -310,10 +325,10 @@ class Storage extends DAV implements ISharedStorage {
'connect_timeout' => 10,
]);
} catch (\GuzzleHttp\Exception\RequestException $e) {
- if ($e->getCode() === 401 || $e->getCode() === 403) {
+ if ($e->getCode() === Http::STATUS_UNAUTHORIZED || $e->getCode() === Http::STATUS_FORBIDDEN) {
throw new ForbiddenException();
}
- if ($e->getCode() === 404) {
+ if ($e->getCode() === Http::STATUS_NOT_FOUND) {
throw new NotFoundException();
}
// throw this to be on the safe side: the share will still be visible
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index 0d41b3bab02..c8088a41c47 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -814,13 +814,13 @@ class DAV extends Common {
private function convertException(Exception $e, $path = '') {
Util::writeLog('files_external', $e->getMessage(), Util::ERROR);
if ($e instanceof ClientHttpException) {
- if ($e->getHttpStatus() === 423) {
+ if ($e->getHttpStatus() === Http::STATUS_LOCKED) {
throw new \OCP\Lock\LockedException($path);
}
- if ($e->getHttpStatus() === 401) {
+ if ($e->getHttpStatus() === Http::STATUS_UNAUTHORIZED) {
// either password was changed or was invalid all along
throw new StorageInvalidException(get_class($e) . ': ' . $e->getMessage());
- } else if ($e->getHttpStatus() === 405) {
+ } else if ($e->getHttpStatus() === Http::STATUS_METHOD_NOT_ALLOWED) {
// ignore exception for MethodNotAllowed, false will be returned
return;
}