From f39fcbc250c3817e0c62627b127cf31a70dca36a Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 25 Feb 2015 16:35:13 +0100 Subject: [PATCH 1/2] Fixes WebDAV copy - added existence check for source argument - removed extra logic for folders, as $view->copy() already supports that internally --- lib/private/connector/sabre/objecttree.php | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php index 585be63781..e13d4ded91 100644 --- a/lib/private/connector/sabre/objecttree.php +++ b/lib/private/connector/sabre/objecttree.php @@ -234,21 +234,11 @@ class ObjectTree extends \Sabre\DAV\Tree { throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup'); } + // this will trigger existence check + $node = $this->getNodeForPath($source); + try { - if ($this->fileView->is_file($source)) { - $this->fileView->copy($source, $destination); - } else { - $this->fileView->mkdir($destination); - $dh = $this->fileView->opendir($source); - if (is_resource($dh)) { - while (($subNode = readdir($dh)) !== false) { - - if ($subNode == '.' || $subNode == '..') continue; - $this->copy($source . '/' . $subNode, $destination . '/' . $subNode); - - } - } - } + $this->fileView->copy($source, $destination); } catch (\OCP\Files\StorageNotAvailableException $e) { throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage()); } From ae2f37ac06514dc53fd192c04aebdf9f51d03b04 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 26 Feb 2015 11:16:42 +0100 Subject: [PATCH 2/2] Removed unused $node variable --- lib/private/connector/sabre/objecttree.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php index e13d4ded91..c841645046 100644 --- a/lib/private/connector/sabre/objecttree.php +++ b/lib/private/connector/sabre/objecttree.php @@ -235,7 +235,7 @@ class ObjectTree extends \Sabre\DAV\Tree { } // this will trigger existence check - $node = $this->getNodeForPath($source); + $this->getNodeForPath($source); try { $this->fileView->copy($source, $destination);