aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/ObjectStore/Swift.php
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-11-16 20:21:21 +0100
committerMorris Jobke <hey@morrisjobke.de>2018-11-19 11:34:38 +0100
commit35251928d57092a50529da8d439c0de3cf428298 (patch)
treee8583cb84419febb9d8f11b83c8a579797f1944a /lib/private/Files/ObjectStore/Swift.php
parenta4d81ba1641db8136b13d2bb7b7c0176c916ec7e (diff)
downloadnextcloud-server-35251928d57092a50529da8d439c0de3cf428298.tar.gz
nextcloud-server-35251928d57092a50529da8d439c0de3cf428298.zip
forward object not found error in switch as dav 404
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/ObjectStore/Swift.php')
-rw-r--r--lib/private/Files/ObjectStore/Swift.php20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php
index 6bb01506c4c..667b92bd1d6 100644
--- a/lib/private/Files/ObjectStore/Swift.php
+++ b/lib/private/Files/ObjectStore/Swift.php
@@ -27,8 +27,10 @@ namespace OC\Files\ObjectStore;
use function GuzzleHttp\Psr7\stream_for;
use Icewind\Streams\RetryWrapper;
+use OCP\Files\NotFoundException;
use OCP\Files\ObjectStore\IObjectStore;
use OCP\Files\StorageAuthException;
+use OpenStack\Common\Error\BadResponseError;
class Swift implements IObjectStore {
/**
@@ -86,11 +88,19 @@ class Swift implements IObjectStore {
* @throws \Exception from openstack lib when something goes wrong
*/
public function readObject($urn) {
- $object = $this->getContainer()->getObject($urn);
-
- // we need to keep a reference to objectContent or
- // the stream will be closed before we can do anything with it
- $objectContent = $object->download();
+ try {
+ $object = $this->getContainer()->getObject($urn);
+
+ // we need to keep a reference to objectContent or
+ // the stream will be closed before we can do anything with it
+ $objectContent = $object->download();
+ } catch (BadResponseError $e) {
+ if ($e->getResponse()->getStatusCode() === 404) {
+ throw new NotFoundException("object $urn not found in object store");
+ } else {
+ throw $e;
+ }
+ }
$objectContent->rewind();
$stream = $objectContent->detach();