Only require CREATE permissions when the file does not exist yet

This commit is contained in:
Joas Schilling 2016-09-07 11:10:48 +02:00
parent 83515c90e9
commit 338ce725c7
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
1 changed files with 11 additions and 2 deletions

View File

@ -202,7 +202,11 @@ class ObjectTree extends \Sabre\DAV\Tree {
$infoDestination = $this->fileView->getFileInfo(dirname($destinationPath)); $infoDestination = $this->fileView->getFileInfo(dirname($destinationPath));
$infoSource = $this->fileView->getFileInfo($sourcePath); $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(); $sourcePermission = $infoSource && $infoSource->isDeletable();
if (!$destinationPermission || !$sourcePermission) { if (!$destinationPermission || !$sourcePermission) {
@ -292,7 +296,12 @@ class ObjectTree extends \Sabre\DAV\Tree {
} }
$info = $this->fileView->getFileInfo(dirname($destination)); $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.'); throw new Forbidden('No permissions to copy object.');
} }