aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-11-19 15:32:27 +0100
committerGitHub <noreply@github.com>2018-11-19 15:32:27 +0100
commit59b4643c72b511c618af82d1eeb56f005ebd4317 (patch)
tree5e24c9305334803f5c38e9645b4ba3a46f789d99
parentc85d6b3d6963660698bbd155ae9ad10c99263910 (diff)
parent5261edb61ab0a234f241d8d29b5140f1433f26d6 (diff)
downloadnextcloud-server-59b4643c72b511c618af82d1eeb56f005ebd4317.tar.gz
nextcloud-server-59b4643c72b511c618af82d1eeb56f005ebd4317.zip
Merge pull request #12503 from nextcloud/swift-object-not-found-13
[13] forward object not found error in swift as dav 404
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php3
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php10
-rw-r--r--lib/private/Files/ObjectStore/Swift.php20
3 files changed, 25 insertions, 8 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index 2b3956e2baf..a3d1861db28 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -50,6 +50,7 @@ use OCP\Files\ForbiddenException;
use OCP\Files\InvalidContentException;
use OCP\Files\InvalidPathException;
use OCP\Files\LockNotAcquiredException;
+use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\StorageNotAvailableException;
use OCP\Lock\ILockingProvider;
@@ -353,6 +354,8 @@ class File extends Node implements IFile {
throw new DAVForbiddenException($ex->getMessage(), $ex->getRetry());
} catch (LockedException $e) {
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
+ } catch (NotFoundException $e) {
+ throw new NotFound('File not found: ' . $e->getMessage(), $e->getCode(), $e);
}
}
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index 4c540071471..1e292520fbd 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 {
@@ -269,10 +271,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 70bc4ed8438..d90545b4f3e 100644
--- a/lib/private/Files/ObjectStore/Swift.php
+++ b/lib/private/Files/ObjectStore/Swift.php
@@ -27,12 +27,14 @@ namespace OC\Files\ObjectStore;
use Guzzle\Http\Exception\ClientErrorResponseException;
use Icewind\Streams\RetryWrapper;
+use OCP\Files\NotFoundException;
use OCP\Files\ObjectStore\IObjectStore;
use OCP\Files\StorageAuthException;
use OCP\Files\StorageNotAvailableException;
use OpenCloud\Common\Service\Catalog;
use OpenCloud\Common\Service\CatalogItem;
use OpenCloud\Identity\Resource\Token;
+use OpenCloud\ObjectStore\Exception\ObjectNotFoundException;
use OpenCloud\ObjectStore\Service;
use OpenCloud\OpenStack;
use OpenCloud\Rackspace;
@@ -252,13 +254,17 @@ class Swift implements IObjectStore {
* @throws Exception from openstack lib when something goes wrong
*/
public function readObject($urn) {
- $this->init();
- $object = $this->container->getObject($urn);
-
- // we need to keep a reference to objectContent or
- // the stream will be closed before we can do anything with it
- /** @var $objectContent \Guzzle\Http\EntityBody * */
- $objectContent = $object->getContent();
+ try {
+ $this->init();
+ $object = $this->container->getObject($urn);
+
+ // we need to keep a reference to objectContent or
+ // the stream will be closed before we can do anything with it
+ /** @var $objectContent \Guzzle\Http\EntityBody * */
+ $objectContent = $object->getContent();
+ } catch (ObjectNotFoundException $e) {
+ throw new NotFoundException("object $urn not found in object store");
+ }
$objectContent->rewind();
$stream = $objectContent->getStream();