Skip to content

Commit

Permalink
Merge pull request #45016 from nextcloud/backport/45001/stable27
Browse files Browse the repository at this point in the history
[stable27] fix(DAV): Migrate known exceptions to Sabre exceptions when copying
  • Loading branch information
nickvergessen authored May 6, 2024
2 parents 18cce2f + 8923c37 commit bf9c3c6
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,20 +467,28 @@ public function moveInto($targetName, $fullSourcePath, INode $sourceNode) {

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;
Expand Down

0 comments on commit bf9c3c6

Please sign in to comment.