]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(DAV): Migrate known exceptions to Sabre exceptions when copying 45001/head
authorJoas Schilling <coding@schilljs.com>
Wed, 24 Apr 2024 05:18:47 +0000 (07:18 +0200)
committerJoas Schilling <coding@schilljs.com>
Wed, 24 Apr 2024 05:18:47 +0000 (07:18 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/dav/lib/Connector/Sabre/Directory.php

index e40b8d760eb4891023bba6956b64d1a37220e9f0..5bfc3e49e42571d5f8dc6494caba0005e7c5929e 100644 (file)
@@ -469,20 +469,28 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
 
        public function copyInto($targetName, $sourcePath, INode $sourceNode) {
                if ($sourceNode instanceof File || $sourceNode instanceof Directory) {
-                       $destinationPath = $this->getPath() . '/' . $targetName;
-                       $sourcePath = $sourceNode->getPath();
+                       try {
+                               $destinationPath = $this->getPath() . '/' . $targetName;
+                               $sourcePath = $sourceNode->getPath();
 
-                       if (!$this->fileView->isCreatable($this->getPath())) {
-                               throw new \Sabre\DAV\Exception\Forbidden();
-                       }
+                               if (!$this->fileView->isCreatable($this->getPath())) {
+                                       throw new \Sabre\DAV\Exception\Forbidden();
+                               }
 
-                       try {
-                               $this->fileView->verifyPath($this->getPath(), $targetName);
-                       } catch (InvalidPathException $ex) {
-                               throw new InvalidPath($ex->getMessage());
-                       }
+                               try {
+                                       $this->fileView->verifyPath($this->getPath(), $targetName);
+                               } catch (InvalidPathException $ex) {
+                                       throw new InvalidPath($ex->getMessage());
+                               }
 
-                       return $this->fileView->copy($sourcePath, $destinationPath);
+                               return $this->fileView->copy($sourcePath, $destinationPath);
+                       } catch (StorageNotAvailableException $e) {
+                               throw new ServiceUnavailable($e->getMessage());
+                       } catch (ForbiddenException $ex) {
+                               throw new Forbidden($ex->getMessage(), $ex->getRetry());
+                       } catch (LockedException $e) {
+                               throw new FileLocked($e->getMessage(), $e->getCode(), $e);
+                       }
                }
 
                return false;