Skip to content

Commit

Permalink
fix share roots always being marked as writable
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed May 10, 2023
1 parent f734a76 commit 18c9f40
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/public/Files/DavUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@

namespace OCP\Files;

use OC\Files\Mount\MoveableMount;
use OCA\Files_Sharing\SharedMount;
use OCA\Files_Sharing\SharedStorage;
use OCP\Constants;

/**
* This class provides different helper functions related to WebDAV protocol
*
Expand Down Expand Up @@ -75,12 +80,23 @@ public static function getDavPermissions(FileInfo $info): string {
if ($info->isUpdateable()) {
$p .= 'NV'; // Renameable, Moveable
}

// since we always add update permissions for the root of movable mounts (and thus shares)
// we need to check the shared cache item directly to determine if it's writable
$storage = $info->getStorage();
if ($info->getInternalPath() === '' && $storage->instanceOfStorage(SharedStorage::class)) {
$shareEntry = $storage->getCache()->get('');
$isWritable = ($shareEntry->getPermissions() & Constants::PERMISSION_UPDATE);
} else {
$isWritable = $info->isUpdateable();
}

if ($info->getType() === FileInfo::TYPE_FILE) {
if ($info->isUpdateable()) {
if ($isWritable) {
$p .= 'W';
}
} else {
if ($info->isCreatable()) {
if ($isWritable) {
$p .= 'CK';
}
}
Expand Down

0 comments on commit 18c9f40

Please sign in to comment.