Skip to content

Commit 8f8b441

Browse files
authored
Merge pull request #57553 from nextcloud/getMountsForPath-args
2 parents b9e670d + 53b160c commit 8f8b441

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

lib/private/Files/Config/MountProviderCollection.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ public function getMountsForUser(IUser $user): array {
8484
}
8585

8686
/**
87-
* @param MountProviderArgs[] $mountProviderArgs
88-
* @return array<string, IMountPoint> IMountPoint array indexed by mount
89-
* point.
87+
* The caller is responsible to ensure that all provided MountProviderArgs
88+
* are for the same user.
89+
* And that the `$providerClass` implements IPartialMountProvider.
90+
*
91+
* @param list<MountProviderArgs> $mountProviderArgs
92+
* @return array<string, IMountPoint> IMountPoint array indexed by mount point.
9093
*/
9194
public function getUserMountsFromProviderByPath(
9295
string $providerClass,
@@ -98,14 +101,16 @@ public function getUserMountsFromProviderByPath(
98101
if ($provider === null) {
99102
return [];
100103
}
104+
if (count($mountProviderArgs) === 0) {
105+
return [];
106+
}
101107

102-
if (!is_a($providerClass, IPartialMountProvider::class, true)) {
108+
if (!$provider instanceof IPartialMountProvider) {
103109
throw new \LogicException(
104110
'Mount provider does not support partial mounts'
105111
);
106112
}
107113

108-
/** @var IPartialMountProvider $provider */
109114
return $provider->getMountsForPath(
110115
$path,
111116
$forChildren,

lib/private/Files/SetupManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ public function setupForPath(string $path, bool $includeChildren = false): void
600600
}
601601
$this->setupMountProviderPaths[$mountPoint] = self::SETUP_WITH_CHILDREN;
602602
foreach ($authoritativeCachedMounts as $providerClass => $cachedMounts) {
603-
$providerArgs = array_filter(array_map(
603+
$providerArgs = array_values(array_filter(array_map(
604604
static function (ICachedMountInfo $info) use ($rootsMetadata) {
605605
$rootMetadata = $rootsMetadata[$info->getRootId()] ?? null;
606606

@@ -609,7 +609,7 @@ static function (ICachedMountInfo $info) use ($rootsMetadata) {
609609
: null;
610610
},
611611
$cachedMounts
612-
));
612+
)));
613613
$authoritativeMounts[] = $this->mountProviderCollection->getUserMountsFromProviderByPath(
614614
$providerClass,
615615
$path,

lib/public/Files/Config/IPartialMountProvider.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
interface IPartialMountProvider extends IMountProvider {
2121

2222
/**
23+
* Get the mounts for a user by path.
24+
*
2325
* Called during the Filesystem setup of a specific path.
2426
*
2527
* The provided arguments give information about the path being set up,
@@ -29,15 +31,28 @@ interface IPartialMountProvider extends IMountProvider {
2931
* Implementations should verify the MountProviderArgs and return the
3032
* corresponding IMountPoint instances.
3133
*
32-
* @param string $path path for which the mounts are set up
33-
* @param bool $forChildren when true, only child mounts for path should be returned
34-
* @param MountProviderArgs[] $mountProviderArgs
34+
* If the mount for one of the MountProviderArgs no longer exists, implementations
35+
* should simply leave them out from the returned mounts.
36+
*
37+
* Implementations are allowed to, but not expected to, return more mounts than requested.
38+
*
39+
* The user for which the mounts are being setup can be found in the `mountInfo->getUser()`
40+
* of a MountProviderArgs.
41+
* All provided MountProviderArgs will always be for the same user.
42+
*
43+
* @param string $setupPathHint path for which the mounts are being set up.
44+
* This might not be the same as the path of the expected mount(s).
45+
* @param bool $forChildren when true, only child mounts for `$setupPathHint` were requested.
46+
* The $mountProviderArgs will hold a list of expected child mounts
47+
* @param non-empty-list<MountProviderArgs> $mountProviderArgs The data for the mount which should be provided.
48+
* Contains the mount information and root-cache-entry
49+
* for each mount the system knows about
50+
* in the scope of the setup request.
3551
* @param IStorageFactory $loader
36-
* @return array<string, IMountPoint> IMountPoint instances, indexed by
37-
* mount-point
52+
* @return array<string, IMountPoint> IMountPoint instances, indexed by mount-point
3853
*/
3954
public function getMountsForPath(
40-
string $path,
55+
string $setupPathHint,
4156
bool $forChildren,
4257
array $mountProviderArgs,
4358
IStorageFactory $loader,

0 commit comments

Comments
 (0)