diff options
author | Morris Jobke <hey@morrisjobke.de> | 2021-01-07 15:29:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-07 15:29:08 +0300 |
commit | ac8a64a59ca5495cc1a9061567e85acc909a673a (patch) | |
tree | 7926c1104bbe60760ad56cf0fcf2613efe151640 | |
parent | 57e165c244cda90f78ee59c293995ae9eeb5ce11 (diff) | |
parent | 31944e84cbae708a7274945dd5d4387cf0a6f103 (diff) |
Merge pull request #24591 from nextcloud/backport/24358/stable19
[stable19] use storage copy implementation when doing dav copy
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Directory.php | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php index e49a2ac3fe6..d7ba67239d5 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -50,7 +50,7 @@ use Sabre\DAV\Exception\ServiceUnavailable; use Sabre\DAV\IFile; use Sabre\DAV\INode; -class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget { +class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget, \Sabre\DAV\ICopyTarget { /** * Cached directory content @@ -393,7 +393,7 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol throw new \Sabre\DAV\Exception\Forbidden('Could not copy directory ' . $sourceNode->getName() . ', target exists'); } - list($sourceDir,) = \Sabre\Uri\split($sourceNode->getPath()); + [$sourceDir,] = \Sabre\Uri\split($sourceNode->getPath()); $destinationDir = $this->getPath(); $sourcePath = $sourceNode->getPath(); @@ -448,4 +448,26 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol return true; } + + + public function copyInto($targetName, $sourcePath, INode $sourceNode) { + if ($sourceNode instanceof File) { + $destinationPath = $this->getPath() . '/' . $targetName; + $sourcePath = $sourceNode->getPath(); + + 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()); + } + + return $this->fileView->copy($sourcePath, $destinationPath); + } + + return false; + } } |