From 2fe6370923cb4b052d7472681a2c6a254f4c6892 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 10 May 2023 15:20:56 +0200 Subject: fix share roots always being marked as writable Signed-off-by: Robin Appelman --- lib/public/Files/DavUtil.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/public/Files/DavUtil.php b/lib/public/Files/DavUtil.php index 343f3c2ac0f..2e7efdccd07 100644 --- a/lib/public/Files/DavUtil.php +++ b/lib/public/Files/DavUtil.php @@ -32,6 +32,9 @@ namespace OCP\Files; +use OCP\Constants; +use OC\Files\Mount\MoveableMount; + /** * This class provides different helper functions related to WebDAV protocol * @@ -73,10 +76,21 @@ class DavUtil { $p .= 'D'; } if ($info->isUpdateable()) { - $p .= 'NV'; // Renameable, Moveable + $p .= 'NV'; // Renameable, Movable } + + // since we always add update permissions for the root of movable mounts + // we need to check the shared cache item directly to determine if it's writable + $storage = $info->getStorage(); + if ($info->getInternalPath() === '' && $info->getMountPoint() instanceof MoveableMount) { + $rootEntry = $storage->getCache()->get(''); + $isWritable = $rootEntry->getPermissions() & Constants::PERMISSION_UPDATE; + } else { + $isWritable = $info->isUpdateable(); + } + if ($info->getType() === FileInfo::TYPE_FILE) { - if ($info->isUpdateable()) { + if ($isWritable) { $p .= 'W'; } } else { -- cgit v1.2.3