summaryrefslogtreecommitdiffstats
path: root/lib/private/Files
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-11-05 19:19:16 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-11-17 09:11:15 +0100
commitc08e803db305edb06bf6a0857a37689bcc19e613 (patch)
tree86a2782a04ac47ec12c3efc62f4866bcd95c926e /lib/private/Files
parent30bdb0f35b4d6caf644a331d53b7cbda0ca5386f (diff)
downloadnextcloud-server-c08e803db305edb06bf6a0857a37689bcc19e613.tar.gz
nextcloud-server-c08e803db305edb06bf6a0857a37689bcc19e613.zip
Catch forbidden http status code
If you try to do something on a DAV mount (external or federated share) that is not allowed. We should not mark the storage as not available but just fail somewhat gracefully. Now by catching this and just properly returning the operation will just fail (and notify the user) which is already a lot better then marking the storage as unavailable and doing boom. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Files')
-rw-r--r--lib/private/Files/Storage/DAV.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index c4ebb0a44dc..2367c1aab3c 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -35,6 +35,7 @@ namespace OC\Files\Storage;
use Exception;
use GuzzleHttp\Exception\RequestException;
+use OCP\Files\ForbiddenException;
use OCP\ILogger;
use Psr\Http\Message\ResponseInterface;
use Icewind\Streams\CallbackWrapper;
@@ -829,6 +830,7 @@ class DAV extends Common {
* when the authentication expired or is invalid
* @throws StorageNotAvailableException if the storage is not available,
* which might be temporary
+ * @throws ForbiddenException if the action is not allowed
*/
protected function convertException(Exception $e, $path = '') {
\OC::$server->getLogger()->logException($e, ['app' => 'files_external', 'level' => ILogger::DEBUG]);
@@ -842,6 +844,9 @@ class DAV extends Common {
} else if ($e->getHttpStatus() === Http::STATUS_METHOD_NOT_ALLOWED) {
// ignore exception for MethodNotAllowed, false will be returned
return;
+ } else if ($e->getHttpStatus() === Http::STATUS_FORBIDDEN){
+ // The operation is forbidden. Fail somewhat gracefully
+ throw new ForbiddenException(get_class($e) . ':' . $e->getMessage());
}
throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
} else if ($e instanceof ClientException) {