From 2f9b54ab386469ac1e1891f87b4e540226f3ab42 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 16 Dec 2024 20:31:14 +0100 Subject: [PATCH 1/3] 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 bcc54dea0dcb1..0c0fe7a0ebfae 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -23,6 +23,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; @@ -85,7 +86,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 @@ -96,8 +97,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); } /** @@ -208,6 +210,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; From 910d25ed5e6ac249879c3ecfa733a10e34f21dfb Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 20 Jan 2025 14:49:23 +0100 Subject: [PATCH 2/3] chore: update baseline Signed-off-by: Robin Appelman --- build/psalm-baseline.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index a8839fd25ffaa..5d52fb931cca6 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -2258,14 +2258,6 @@ - - - - - - - - From a2bcf725a6d6c96fd7ec7f05ee2a3b46c56d7371 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 20 Jan 2025 15:31:05 +0100 Subject: [PATCH 3/3] chore: psalm fixes Signed-off-by: Robin Appelman --- lib/private/Files/Utils/Scanner.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index 0c0fe7a0ebfae..476448f99c579 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -147,6 +147,7 @@ public function backgroundScan($dir) { continue; } + /** @var \OC\Files\Cache\Scanner $scanner */ $scanner = $storage->getScanner(); $this->attachListener($mount); @@ -226,6 +227,7 @@ public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECUR continue; } $relativePath = $mount->getInternalPath($dir); + /** @var \OC\Files\Cache\Scanner $scanner */ $scanner = $storage->getScanner(); $scanner->setUseTransactions(false); $this->attachListener($mount);