Skip to content

Commit f198508

Browse files
authored
Merge pull request #49887 from nextcloud/scan-home-ext-storae
fix: don't skip scanner users filesystem if they have a mountpoint at /<user>/files/
2 parents f9e6b1f + 7bc8eb3 commit f198508

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

build/psalm-baseline.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,14 +2101,6 @@
21012101
<code><![CDATA[$mimetype]]></code>
21022102
</ParamNameMismatch>
21032103
</file>
2104-
<file src="lib/private/Files/Utils/Scanner.php">
2105-
<LessSpecificReturnStatement>
2106-
<code><![CDATA[$mounts]]></code>
2107-
</LessSpecificReturnStatement>
2108-
<MoreSpecificReturnType>
2109-
<code><![CDATA[\OC\Files\Mount\MountPoint[]]]></code>
2110-
</MoreSpecificReturnType>
2111-
</file>
21122104
<file src="lib/private/Files/View.php">
21132105
<InvalidScalarArgument>
21142106
<code><![CDATA[$mtime]]></code>

lib/private/Files/Utils/Scanner.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use OCP\Files\Events\FolderScannedEvent;
2424
use OCP\Files\Events\NodeAddedToCache;
2525
use OCP\Files\Events\NodeRemovedFromCache;
26+
use OCP\Files\Mount\IMountPoint;
2627
use OCP\Files\NotFoundException;
2728
use OCP\Files\Storage\IStorage;
2829
use OCP\Files\StorageNotAvailableException;
@@ -85,7 +86,7 @@ public function __construct($user, $db, IEventDispatcher $dispatcher, LoggerInte
8586
* get all storages for $dir
8687
*
8788
* @param string $dir
88-
* @return \OC\Files\Mount\MountPoint[]
89+
* @return array<string, IMountPoint>
8990
*/
9091
protected function getMounts($dir) {
9192
//TODO: move to the node based fileapi once that's done
@@ -96,8 +97,9 @@ protected function getMounts($dir) {
9697
$mounts = $mountManager->findIn($dir);
9798
$mounts[] = $mountManager->find($dir);
9899
$mounts = array_reverse($mounts); //start with the mount of $dir
100+
$mountPoints = array_map(fn ($mount) => $mount->getMountPoint(), $mounts);
99101

100-
return $mounts;
102+
return array_combine($mountPoints, $mounts);
101103
}
102104

103105
/**
@@ -210,6 +212,9 @@ public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECUR
210212
$owner = $owner['name'] ?? $ownerUid;
211213
$permissions = decoct(fileperms($fullPath));
212214
throw new ForbiddenException("User folder $fullPath is not writable, folders is owned by $owner and has mode $permissions");
215+
} elseif (isset($mounts[$mount->getMountPoint() . $path . '/'])) {
216+
// /<user>/files is overwritten by a mountpoint, so this check is irrelevant
217+
break;
213218
} else {
214219
// if the root exists in neither the cache nor the storage the user isn't setup yet
215220
break 2;

0 commit comments

Comments
 (0)