File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed
apps/dav/lib/Connector/Sabre
lib/private/Files/ObjectStore Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 5050use OCP \Files \InvalidContentException ;
5151use OCP \Files \InvalidPathException ;
5252use OCP \Files \LockNotAcquiredException ;
53+ use OCP \Files \NotFoundException ;
5354use OCP \Files \NotPermittedException ;
5455use OCP \Files \Storage ;
5556use OCP \Files \StorageNotAvailableException ;
@@ -583,6 +584,9 @@ private function convertToSabreException(\Exception $e) {
583584 if ($ e instanceof StorageNotAvailableException) {
584585 throw new ServiceUnavailable ('Failed to write file contents: ' . $ e ->getMessage (), 0 , $ e );
585586 }
587+ if ($ e instanceof NotFoundException) {
588+ throw new NotFound ('File not found: ' . $ e ->getMessage (), 0 , $ e );
589+ }
586590
587591 throw new \Sabre \DAV \Exception ($ e ->getMessage (), 0 , $ e );
588592 }
Original file line number Diff line number Diff line change 2828use Icewind \Streams \CallbackWrapper ;
2929use Icewind \Streams \IteratorDirectory ;
3030use OC \Files \Cache \CacheEntry ;
31+ use OC \Files \Stream \CountReadStream ;
32+ use OCP \Files \NotFoundException ;
3133use OCP \Files \ObjectStore \IObjectStore ;
3234
3335class ObjectStoreStorage extends \OC \Files \Storage \Common {
@@ -274,6 +276,12 @@ public function fopen($path, $mode) {
274276 if (is_array ($ stat )) {
275277 try {
276278 return $ this ->objectStore ->readObject ($ this ->getURN ($ stat ['fileid ' ]));
279+ } catch (NotFoundException $ e ) {
280+ $ this ->logger ->logException ($ e , [
281+ 'app ' => 'objectstore ' ,
282+ 'message ' => 'Count not get object ' . $ this ->getURN ($ stat ['fileid ' ]) . ' for file ' . $ path ,
283+ ]);
284+ throw $ e ;
277285 } catch (\Exception $ ex ) {
278286 $ this ->logger ->logException ($ ex , [
279287 'app ' => 'objectstore ' ,
Original file line number Diff line number Diff line change 2727
2828use function GuzzleHttp \Psr7 \stream_for ;
2929use Icewind \Streams \RetryWrapper ;
30+ use OCP \Files \NotFoundException ;
3031use OCP \Files \ObjectStore \IObjectStore ;
3132use OCP \Files \StorageAuthException ;
33+ use OpenStack \Common \Error \BadResponseError ;
3234
3335class Swift implements IObjectStore {
3436 /**
@@ -86,11 +88,19 @@ public function writeObject($urn, $stream) {
8688 * @throws \Exception from openstack lib when something goes wrong
8789 */
8890 public function readObject ($ urn ) {
89- $ object = $ this ->getContainer ()->getObject ($ urn );
90-
91- // we need to keep a reference to objectContent or
92- // the stream will be closed before we can do anything with it
93- $ objectContent = $ object ->download ();
91+ try {
92+ $ object = $ this ->getContainer ()->getObject ($ urn );
93+
94+ // we need to keep a reference to objectContent or
95+ // the stream will be closed before we can do anything with it
96+ $ objectContent = $ object ->download ();
97+ } catch (BadResponseError $ e ) {
98+ if ($ e ->getResponse ()->getStatusCode () === 404 ) {
99+ throw new NotFoundException ("object $ urn not found in object store " );
100+ } else {
101+ throw $ e ;
102+ }
103+ }
94104 $ objectContent ->rewind ();
95105
96106 $ stream = $ objectContent ->detach ();
You can’t perform that action at this time.
0 commit comments