From 43c37426cbd6a00db8022dc88d5a909fc414a1ec Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 16 Dec 2024 20:31:14 +0100 Subject: [PATCH] fix: don't skip scanner users filesystem if they have a mountpoint at //files/ Signed-off-by: Robin Appelman --- lib/private/Files/Utils/Scanner.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index 997d6e1a34ed8..f5e9cda29882e 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -46,6 +46,7 @@ use OCP\Files\Events\FolderScannedEvent; use OCP\Files\Events\NodeAddedToCache; use OCP\Files\Events\NodeRemovedFromCache; +use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorage; use OCP\Files\StorageNotAvailableException; @@ -108,7 +109,7 @@ public function __construct($user, $db, IEventDispatcher $dispatcher, LoggerInte * get all storages for $dir * * @param string $dir - * @return \OC\Files\Mount\MountPoint[] + * @return array */ protected function getMounts($dir) { //TODO: move to the node based fileapi once that's done @@ -119,8 +120,9 @@ protected function getMounts($dir) { $mounts = $mountManager->findIn($dir); $mounts[] = $mountManager->find($dir); $mounts = array_reverse($mounts); //start with the mount of $dir + $mountPoints = array_map(fn ($mount) => $mount->getMountPoint(), $mounts); - return $mounts; + return array_combine($mountPoints, $mounts); } /** @@ -231,6 +233,9 @@ public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECUR $owner = $owner['name'] ?? $ownerUid; $permissions = decoct(fileperms($fullPath)); throw new ForbiddenException("User folder $fullPath is not writable, folders is owned by $owner and has mode $permissions"); + } elseif (isset($mounts[$mount->getMountPoint() . $path . '/'])) { + // //files is overwritten by a mountpoint, so this check is irrelevant + break; } else { // if the root exists in neither the cache nor the storage the user isn't setup yet break 2;