瀏覽代碼

Merge pull request #45001 from nextcloud/bugfix/noid/convert-exceptions-to-sabre-exceptions

fix(DAV): Migrate known exceptions to Sabre exceptions when copying
pull/45020/head
Julius Härtl 3 週之前
父節點
當前提交
153705d17c
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 19 行新增11 行删除
  1. 19
    11
      apps/dav/lib/Connector/Sabre/Directory.php

+ 19
- 11
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;

Loading…
取消
儲存