Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions lib/private/Files/Config/UserMountCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,10 @@ public function clear(): void {
}

public function getMountForPath(IUser $user, string $path): ICachedMountInfo {
$mounts = $this->getMountsForUser($user);
$mountPoints = array_map(function (ICachedMountInfo $mount) {
return $mount->getMountPoint();
}, $mounts);
$mounts = array_combine($mountPoints, $mounts);
$mounts = [];
foreach ($this->getMountsForUser($user) as $mount) {
$mounts[$mount->getMountPoint()] = $mount;
}

$current = rtrim($path, '/');
// walk up the directory tree until we find a path that has a mountpoint set
Expand All @@ -519,9 +518,13 @@ public function getMountForPath(IUser $user, string $path): ICachedMountInfo {

public function getMountsInPath(IUser $user, string $path): array {
$path = rtrim($path, '/') . '/';
$mounts = $this->getMountsForUser($user);
return array_filter($mounts, function (ICachedMountInfo $mount) use ($path) {
return $mount->getMountPoint() !== $path && str_starts_with($mount->getMountPoint(), $path);
});
$result = [];
foreach ($this->getMountsForUser($user) as $key => $mount) {
$mountPoint = $mount->getMountPoint();
if ($mountPoint !== $path && str_starts_with($mountPoint, $path)) {
$result[$key] = $mount;
}
}
return $result;
}
}
Loading