]> source.dussan.org Git - nextcloud-server.git/commitdiff
Only require CREATE permissions when the file does not exist yet
authorJoas Schilling <coding@schilljs.com>
Wed, 7 Sep 2016 09:10:48 +0000 (11:10 +0200)
committerJoas Schilling <coding@schilljs.com>
Wed, 7 Sep 2016 09:10:48 +0000 (11:10 +0200)
apps/dav/lib/Connector/Sabre/ObjectTree.php

index e872ea58279adbbac33d840aa059795ec80c60dd..9f6eb8a85b01dae33e1c2626c680d3c382328690 100644 (file)
@@ -205,7 +205,11 @@ class ObjectTree extends \Sabre\DAV\Tree {
 
                $infoDestination = $this->fileView->getFileInfo(dirname($destinationPath));
                $infoSource = $this->fileView->getFileInfo($sourcePath);
-               $destinationPermission = $infoDestination && $infoDestination->isUpdateable();
+               if ($this->fileView->file_exists($destinationPath)) {
+                       $destinationPermission = $infoDestination && $infoDestination->isUpdateable();
+               } else {
+                       $destinationPermission = $infoDestination && $infoDestination->isCreatable();
+               }
                $sourcePermission =  $infoSource && $infoSource->isDeletable();
 
                if (!$destinationPermission || !$sourcePermission) {
@@ -298,7 +302,12 @@ class ObjectTree extends \Sabre\DAV\Tree {
 
 
                $info = $this->fileView->getFileInfo(dirname($destination));
-               if ($info && !$info->isUpdateable()) {
+               if ($this->fileView->file_exists($destination)) {
+                       $destinationPermission = $info && $info->isUpdateable();
+               } else {
+                       $destinationPermission = $info && $info->isCreatable();
+               }
+               if (!$destinationPermission) {
                        throw new Forbidden('No permissions to copy object.');
                }