3535use OC \Files \Filesystem ;
3636use OCA \DAV \Connector \Sabre \Exception \EntityTooLarge ;
3737use OCA \DAV \Connector \Sabre \Exception \FileLocked ;
38+ use OCA \DAV \Connector \Sabre \Exception \Forbidden as DAVForbiddenException ;
3839use OCA \DAV \Connector \Sabre \Exception \UnsupportedMediaType ;
3940use OCP \Encryption \Exceptions \GenericEncryptionException ;
4041use OCP \Files \EntityTooLargeException ;
42+ use OCP \Files \ForbiddenException ;
4143use OCP \Files \InvalidContentException ;
4244use OCP \Files \InvalidPathException ;
4345use OCP \Files \LockNotAcquiredException ;
@@ -175,6 +177,8 @@ public function put($data) {
175177 \OCP \Util::writeLog ('webdav ' , 'renaming part file to final file failed ' , \OCP \Util::ERROR );
176178 throw new Exception ('Could not rename part file to final file ' );
177179 }
180+ } catch (ForbiddenException $ ex ) {
181+ throw new DAVForbiddenException ($ ex ->getMessage (), $ ex ->getRetry ());
178182 } catch (\Exception $ e ) {
179183 $ partStorage ->unlink ($ internalPartPath );
180184 $ this ->convertToSabreException ($ e );
@@ -273,6 +277,8 @@ public function get() {
273277 throw new ServiceUnavailable ("Encryption not ready: " . $ e ->getMessage ());
274278 } catch (StorageNotAvailableException $ e ) {
275279 throw new ServiceUnavailable ("Failed to open file: " . $ e ->getMessage ());
280+ } catch (ForbiddenException $ ex ) {
281+ throw new DAVForbiddenException ($ ex ->getMessage (), $ ex ->getRetry ());
276282 } catch (LockedException $ e ) {
277283 throw new FileLocked ($ e ->getMessage (), $ e ->getCode (), $ e );
278284 }
@@ -296,6 +302,8 @@ public function delete() {
296302 }
297303 } catch (StorageNotAvailableException $ e ) {
298304 throw new ServiceUnavailable ("Failed to unlink: " . $ e ->getMessage ());
305+ } catch (ForbiddenException $ ex ) {
306+ throw new DAVForbiddenException ($ ex ->getMessage (), $ ex ->getRetry ());
299307 } catch (LockedException $ e ) {
300308 throw new FileLocked ($ e ->getMessage (), $ e ->getCode (), $ e );
301309 }
@@ -474,6 +482,10 @@ private function convertToSabreException(\Exception $e) {
474482 // a more general case - due to whatever reason the content could not be written
475483 throw new Forbidden ($ e ->getMessage (), 0 , $ e );
476484 }
485+ if ($ e instanceof ForbiddenException) {
486+ // the path for the file was forbidden
487+ throw new DAVForbiddenException ($ e ->getMessage (), $ e ->getRetry (), $ e );
488+ }
477489 if ($ e instanceof EntityTooLargeException) {
478490 // the file is too big to be stored
479491 throw new EntityTooLarge ($ e ->getMessage (), 0 , $ e );
0 commit comments