Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13] forward object not found error in swift as dav 404 #12503

Merged
merged 1 commit into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
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;
Expand Down Expand Up @@ -353,6 +354,8 @@ public function get() {
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);
}
}

Expand Down
10 changes: 9 additions & 1 deletion lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
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 {
Expand Down Expand Up @@ -269,10 +271,16 @@ public function fopen($path, $mode) {
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;
}
Expand Down
20 changes: 13 additions & 7 deletions lib/private/Files/ObjectStore/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@

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;
Expand Down Expand Up @@ -252,13 +254,17 @@ public function writeObject($urn, $stream) {
* @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();
Expand Down