Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 10 additions & 5 deletions lib/private/Files/Config/MountProviderCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ public function getMountsForUser(IUser $user): array {
}

/**
* @param MountProviderArgs[] $mountProviderArgs
* @return array<string, IMountPoint> IMountPoint array indexed by mount
* point.
* The caller is responsible to ensure that all provided MountProviderArgs
* are for the same user.
* And that the `$providerClass` implements IPartialMountProvider.
*
* @param list<MountProviderArgs> $mountProviderArgs
* @return array<string, IMountPoint> IMountPoint array indexed by mount point.
*/
public function getUserMountsFromProviderByPath(
string $providerClass,
Expand All @@ -98,14 +101,16 @@ public function getUserMountsFromProviderByPath(
if ($provider === null) {
return [];
}
if (count($mountProviderArgs) === 0) {
return [];
}

if (!is_a($providerClass, IPartialMountProvider::class, true)) {
if (!$provider instanceof IPartialMountProvider) {
throw new \LogicException(
'Mount provider does not support partial mounts'
);
}

/** @var IPartialMountProvider $provider */
return $provider->getMountsForPath(
$path,
$forChildren,
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Files/SetupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ public function setupForPath(string $path, bool $includeChildren = false): void
}
$this->setupMountProviderPaths[$mountPoint] = self::SETUP_WITH_CHILDREN;
foreach ($authoritativeCachedMounts as $providerClass => $cachedMounts) {
$providerArgs = array_filter(array_map(
$providerArgs = array_values(array_filter(array_map(
static function (ICachedMountInfo $info) use ($rootsMetadata) {
$rootMetadata = $rootsMetadata[$info->getRootId()] ?? null;

Expand All @@ -609,7 +609,7 @@ static function (ICachedMountInfo $info) use ($rootsMetadata) {
: null;
},
$cachedMounts
));
)));
$authoritativeMounts[] = $this->mountProviderCollection->getUserMountsFromProviderByPath(
$providerClass,
$path,
Expand Down
27 changes: 21 additions & 6 deletions lib/public/Files/Config/IPartialMountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
interface IPartialMountProvider extends IMountProvider {

/**
* Get the mounts for a user by path.
*
* Called during the Filesystem setup of a specific path.
*
* The provided arguments give information about the path being set up,
Expand All @@ -29,15 +31,28 @@ interface IPartialMountProvider extends IMountProvider {
* Implementations should verify the MountProviderArgs and return the
* corresponding IMountPoint instances.
*
* @param string $path path for which the mounts are set up
* @param bool $forChildren when true, only child mounts for path should be returned
* @param MountProviderArgs[] $mountProviderArgs
* If the mount for one of the MountProviderArgs no longer exists, implementations
* should simply leave them out from the returned mounts.
*
* Implementations are allowed to, but not expected to, return more mounts than requested.
*
* The user for which the mounts are being setup can be found in the `mountInfo->getUser()`
* of a MountProviderArgs.
* All provided MountProviderArgs will always be for the same user.
*
* @param string $setupPathHint path for which the mounts are being set up.
* This might not be the same as the path of the expected mount(s).
* @param bool $forChildren when true, only child mounts for `$setupPathHint` were requested.
* The $mountProviderArgs will hold a list of expected child mounts
* @param non-empty-list<MountProviderArgs> $mountProviderArgs The data for the mount which should be provided.
* Contains the mount information and root-cache-entry
* for each mount the system knows about
* in the scope of the setup request.
* @param IStorageFactory $loader
* @return array<string, IMountPoint> IMountPoint instances, indexed by
* mount-point
* @return array<string, IMountPoint> IMountPoint instances, indexed by mount-point
*/
public function getMountsForPath(
string $path,
string $setupPathHint,
bool $forChildren,
array $mountProviderArgs,
IStorageFactory $loader,
Expand Down
Loading