diff options
Diffstat (limited to 'lib/private/Files/ObjectStore/Swift.php')
-rw-r--r-- | lib/private/Files/ObjectStore/Swift.php | 20 |
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(); |