Browse Source

fix(DAV): Migrate known exceptions to Sabre exceptions when copying

Signed-off-by: Joas Schilling <coding@schilljs.com>
tags/v27.1.10rc1
Joas Schilling 1 month ago
parent
commit
8923c37f57
1 changed files with 19 additions and 11 deletions
  1. 19
    11
      apps/dav/lib/Connector/Sabre/Directory.php

+ 19
- 11
apps/dav/lib/Connector/Sabre/Directory.php View File



public function copyInto($targetName, $sourcePath, INode $sourceNode) { public function copyInto($targetName, $sourcePath, INode $sourceNode) {
if ($sourceNode instanceof File || $sourceNode instanceof Directory) { 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; return false;

Loading…
Cancel
Save