Skip to content

Commit

Permalink
Merge pull request #49887 from nextcloud/scan-home-ext-storae
Browse files Browse the repository at this point in the history
fix: don't skip scanner users filesystem if they have a mountpoint at /<user>/files/
  • Loading branch information
skjnldsv authored Dec 28, 2024
2 parents f9e6b1f + 7bc8eb3 commit f198508
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 0 additions & 8 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2101,14 +2101,6 @@
<code><![CDATA[$mimetype]]></code>
</ParamNameMismatch>
</file>
<file src="lib/private/Files/Utils/Scanner.php">
<LessSpecificReturnStatement>
<code><![CDATA[$mounts]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[\OC\Files\Mount\MountPoint[]]]></code>
</MoreSpecificReturnType>
</file>
<file src="lib/private/Files/View.php">
<InvalidScalarArgument>
<code><![CDATA[$mtime]]></code>
Expand Down
9 changes: 7 additions & 2 deletions lib/private/Files/Utils/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<string, IMountPoint>
*/
protected function getMounts($dir) {
//TODO: move to the node based fileapi once that's done
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -210,6 +212,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 . '/'])) {
// /<user>/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;
Expand Down

0 comments on commit f198508

Please sign in to comment.