summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-05-06 07:59:19 +0200
committerGitHub <noreply@github.com>2024-05-06 07:59:19 +0200
commitbf9c3c6a4488fd1af26e61527369ce36842fc1fb (patch)
tree7f3d426a39f0e2c6c752b32aa4cd3a3b991457d2
parent18cce2fd9c5ce121551f37bca5c0128308664121 (diff)
parent8923c37f57de1639d4967ab339781593f60ab667 (diff)
downloadnextcloud-server-bf9c3c6a4488fd1af26e61527369ce36842fc1fb.tar.gz
nextcloud-server-bf9c3c6a4488fd1af26e61527369ce36842fc1fb.zip
Merge pull request #45016 from nextcloud/backport/45001/stable27
[stable27] fix(DAV): Migrate known exceptions to Sabre exceptions when copying
-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 49354deb778..579c9fe5169 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -467,20 +467,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;