summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2021-01-07 14:08:17 +0100
committerGitHub <noreply@github.com>2021-01-07 14:08:17 +0100
commit8295cc90d83fd605ce05f915d5c41a30879f42f3 (patch)
tree789ed01286572b6b1e1cb7dce2ab6e4e7a13155e
parentfb0067a77728f528e302f0052fd9b9389c2f9948 (diff)
parent6790369cfe03b3b9960a5402695609ba4f259c2b (diff)
downloadnextcloud-server-8295cc90d83fd605ce05f915d5c41a30879f42f3.tar.gz
nextcloud-server-8295cc90d83fd605ce05f915d5c41a30879f42f3.zip
Merge pull request #24590 from nextcloud/backport/24358/stable20
[stable20] use storage copy implementation when doing dav copy
-rw-r--r--apps/dav/lib/Connector/Sabre/Directory.php26
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 ede81703968..cb9a4121d1b 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -51,7 +51,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
@@ -394,7 +394,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();
@@ -449,4 +449,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;
+ }
}