Skip to content

Commit 865ee69

Browse files
committed
fix(ViewOnlyPlugin): Allow COPY and MOVE operations within the same storage
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent cf9e05e commit 865ee69

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

apps/dav/lib/DAV/ViewOnlyPlugin.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace OCA\DAV\DAV;
1010

11+
use OCA\DAV\Connector\Sabre\Directory;
1112
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
1213
use OCA\DAV\Connector\Sabre\File as DavFile;
1314
use OCA\Files_Versions\Sabre\VersionFile;
@@ -95,6 +96,17 @@ public function checkViewOnly(RequestInterface $request): bool {
9596
break;
9697
case 'COPY':
9798
case 'MOVE':
99+
$destinationPath = $this->server->getCopyAndMoveInfo($request)['destination'];
100+
$destinationParentPath = dirname($destinationPath);
101+
if ($destinationParentPath === '.') {
102+
$destinationParentPath = '';
103+
}
104+
$destinationParent = $this->server->tree->getNodeForPath($destinationParentPath);
105+
// Copy and move operations within the same storage are allowed, because the destination has the same restrictions.
106+
if (($destinationParent instanceof Directory) && $destinationParent->getNode()->getStorage()->getId() === $storage->getId()) {
107+
break;
108+
}
109+
98110
// If download is disabled, we disable the COPY and MOVE methods even if the shareapi_allow_view_without_download is set to true.
99111
if (!$share->canDownload()) {
100112
throw new Forbidden('Access to this shared resource has been denied because its download permission is disabled.');

0 commit comments

Comments
 (0)