summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Connector
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-12-03 15:03:13 +0100
committerGitHub <noreply@github.com>2020-12-03 15:03:13 +0100
commitfc57f60ece173d3f3b13a2d88e8b5db83ea6427e (patch)
tree0acd24159eda97fef381f8fd443c50572c64a724 /apps/dav/lib/Connector
parent64bc7c79e8e2f60b80eb56c821a2c2d62d123e43 (diff)
parent5ca0de2dee344a0ced096197a38f6346e1a53ddc (diff)
downloadnextcloud-server-fc57f60ece173d3f3b13a2d88e8b5db83ea6427e.tar.gz
nextcloud-server-fc57f60ece173d3f3b13a2d88e8b5db83ea6427e.zip
Merge pull request #24358 from nextcloud/dav-storage-copy
use storage copy implementation when doing dav copy
Diffstat (limited to 'apps/dav/lib/Connector')
-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;
+ }
}