diff options
author | Robin Appelman <robin@icewind.nl> | 2018-11-16 20:21:21 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-11-19 11:36:33 +0100 |
commit | f43cfd9275d7f6d1be325c8630e19b0bf4e81b77 (patch) | |
tree | a3e60384bed1acd4a941c1b1cd9754fd06e3beb9 /lib/private | |
parent | a79c7c7b0554fa09bf5132a08cb2f53cb5470b91 (diff) | |
download | nextcloud-server-f43cfd9275d7f6d1be325c8630e19b0bf4e81b77.tar.gz nextcloud-server-f43cfd9275d7f6d1be325c8630e19b0bf4e81b77.zip |
forward object not found error in swift as dav 404
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/ObjectStore/ObjectStoreStorage.php | 10 | ||||
-rw-r--r-- | lib/private/Files/ObjectStore/Swift.php | 20 |
2 files changed, 24 insertions, 6 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 3ce919a4cbe..d8649129d90 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -28,6 +28,8 @@ namespace OC\Files\ObjectStore; use Icewind\Streams\CallbackWrapper; use Icewind\Streams\IteratorDirectory; use OC\Files\Cache\CacheEntry; +use OC\Files\Stream\CountReadStream; +use OCP\Files\NotFoundException; use OCP\Files\ObjectStore\IObjectStore; class ObjectStoreStorage extends \OC\Files\Storage\Common { @@ -274,10 +276,16 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { if (is_array($stat)) { try { return $this->objectStore->readObject($this->getURN($stat['fileid'])); + } catch (NotFoundException $e) { + $this->logger->logException($e, [ + 'app' => 'objectstore', + 'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path, + ]); + throw $e; } catch (\Exception $ex) { $this->logger->logException($ex, [ 'app' => 'objectstore', - 'message' => 'Count not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path, + 'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path, ]); return false; } 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(); |