aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-04-24 07:18:47 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-04-24 16:31:29 +0000
commitf294ea13a82d74e5680f339b8f44652c7c7b08f0 (patch)
tree703833d990960a891158d04d366ef3dd5103f613 /apps/dav/lib
parentfc8bbf615433f6a769e548b2acf854e827f42b7a (diff)
downloadnextcloud-server-f294ea13a82d74e5680f339b8f44652c7c7b08f0.tar.gz
nextcloud-server-f294ea13a82d74e5680f339b8f44652c7c7b08f0.zip
fix(DAV): Migrate known exceptions to Sabre exceptions when copying
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/Connector/Sabre/Directory.php30
1 files changed, 19 insertions, 11 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index 441e6ea8f57..0aa9e169228 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -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;