Skip to content

Commit 3287a6f

Browse files
committed
fixup! WIP: add a second path for setupForPath for authoritative setup
Signed-off-by: Salvatore Martire <[email protected]> Adds IMountProviderArgs
1 parent d25af41 commit 3287a6f

File tree

6 files changed

+59
-34
lines changed

6 files changed

+59
-34
lines changed

lib/composer/composer/autoload_classmap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,9 @@
416416
'OCP\\Files\\Config\\ICachedMountInfo' => $baseDir . '/lib/public/Files/Config/ICachedMountInfo.php',
417417
'OCP\\Files\\Config\\IHomeMountProvider' => $baseDir . '/lib/public/Files/Config/IHomeMountProvider.php',
418418
'OCP\\Files\\Config\\IMountProvider' => $baseDir . '/lib/public/Files/Config/IMountProvider.php',
419+
'OCP\\Files\\Config\\IMountProviderArgs' => $baseDir . '/lib/public/Files/Config/IMountProviderArgs.php',
419420
'OCP\\Files\\Config\\IMountProviderCollection' => $baseDir . '/lib/public/Files/Config/IMountProviderCollection.php',
421+
'OCP\\Files\\Config\\IPartialMountProvider' => $baseDir . '/lib/public/Files/Config/IPartialMountProvider.php',
420422
'OCP\\Files\\Config\\IRootMountProvider' => $baseDir . '/lib/public/Files/Config/IRootMountProvider.php',
421423
'OCP\\Files\\Config\\IUserMountCache' => $baseDir . '/lib/public/Files/Config/IUserMountCache.php',
422424
'OCP\\Files\\ConnectionLostException' => $baseDir . '/lib/public/Files/ConnectionLostException.php',
@@ -1655,6 +1657,7 @@
16551657
'OC\\Files\\Cache\\CacheQueryBuilder' => $baseDir . '/lib/private/Files/Cache/CacheQueryBuilder.php',
16561658
'OC\\Files\\Cache\\FailedCache' => $baseDir . '/lib/private/Files/Cache/FailedCache.php',
16571659
'OC\\Files\\Cache\\FileAccess' => $baseDir . '/lib/private/Files/Cache/FileAccess.php',
1660+
'OC\\Files\\Cache\\FileMetadataCache' => $baseDir . '/lib/private/Files/Cache/FileMetadataCache.php',
16581661
'OC\\Files\\Cache\\HomeCache' => $baseDir . '/lib/private/Files/Cache/HomeCache.php',
16591662
'OC\\Files\\Cache\\HomePropagator' => $baseDir . '/lib/private/Files/Cache/HomePropagator.php',
16601663
'OC\\Files\\Cache\\LocalRootScanner' => $baseDir . '/lib/private/Files/Cache/LocalRootScanner.php',

lib/composer/composer/autoload_static.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,9 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
457457
'OCP\\Files\\Config\\ICachedMountInfo' => __DIR__ . '/../../..' . '/lib/public/Files/Config/ICachedMountInfo.php',
458458
'OCP\\Files\\Config\\IHomeMountProvider' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IHomeMountProvider.php',
459459
'OCP\\Files\\Config\\IMountProvider' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IMountProvider.php',
460+
'OCP\\Files\\Config\\IMountProviderArgs' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IMountProviderArgs.php',
460461
'OCP\\Files\\Config\\IMountProviderCollection' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IMountProviderCollection.php',
462+
'OCP\\Files\\Config\\IPartialMountProvider' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IPartialMountProvider.php',
461463
'OCP\\Files\\Config\\IRootMountProvider' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IRootMountProvider.php',
462464
'OCP\\Files\\Config\\IUserMountCache' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IUserMountCache.php',
463465
'OCP\\Files\\ConnectionLostException' => __DIR__ . '/../../..' . '/lib/public/Files/ConnectionLostException.php',
@@ -1696,6 +1698,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
16961698
'OC\\Files\\Cache\\CacheQueryBuilder' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/CacheQueryBuilder.php',
16971699
'OC\\Files\\Cache\\FailedCache' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/FailedCache.php',
16981700
'OC\\Files\\Cache\\FileAccess' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/FileAccess.php',
1701+
'OC\\Files\\Cache\\FileMetadataCache' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/FileMetadataCache.php',
16991702
'OC\\Files\\Cache\\HomeCache' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/HomeCache.php',
17001703
'OC\\Files\\Cache\\HomePropagator' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/HomePropagator.php',
17011704
'OC\\Files\\Cache\\LocalRootScanner' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/LocalRootScanner.php',

lib/private/Files/Config/MountProviderCollection.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
use OC\Hooks\EmitterTrait;
1212
use OCA\Files_Sharing\MountProvider;
1313
use OCP\Diagnostics\IEventLogger;
14-
use OCP\Files\Cache\ICacheEntry;
15-
use OCP\Files\Config\ICachedMountInfo;
1614
use OCP\Files\Config\IHomeMountProvider;
1715
use OCP\Files\Config\IMountProvider;
16+
use OCP\Files\Config\IMountProviderArgs;
1817
use OCP\Files\Config\IMountProviderCollection;
1918
use OCP\Files\Config\IPartialMountProvider;
2019
use OCP\Files\Config\IRootMountProvider;
@@ -85,15 +84,14 @@ public function getMountsForUser(IUser $user): array {
8584
}
8685

8786
/**
88-
* @param ICacheEntry[] $mountsMetadata
89-
* @param ICachedMountInfo[] $mountsInfo
90-
* @return IMountPoint[]
87+
* @param IMountProviderArgs[] $mountProviderArgs
88+
* @return array<string, IMountPoint> IMountPoint array indexed by mount
89+
* point.
9190
*/
9291
public function getUserMountsFromProviderByPath(
9392
string $providerClass,
9493
string $path,
95-
array $mountsInfo,
96-
array $mountsMetadata,
94+
array $mountProviderArgs,
9795
): array {
9896
$provider = $this->providers[$providerClass] ?? null;
9997
if ($provider === null) {
@@ -106,10 +104,10 @@ public function getUserMountsFromProviderByPath(
106104
);
107105
}
108106

107+
/** @var IPartialMountProvider $provider */
109108
return $provider->getMountsFromMountPoints(
110109
$path,
111-
$mountsInfo,
112-
$mountsMetadata,
110+
$mountProviderArgs,
113111
$this->loader,
114112
);
115113
}

lib/private/Files/SetupManager.php

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use OCP\Files\Config\ICachedMountInfo;
3636
use OCP\Files\Config\IHomeMountProvider;
3737
use OCP\Files\Config\IMountProvider;
38+
use OCP\Files\Config\IMountProviderArgs;
3839
use OCP\Files\Config\IPartialMountProvider;
3940
use OCP\Files\Config\IRootMountProvider;
4041
use OCP\Files\Config\IUserMountCache;
@@ -525,19 +526,19 @@ public function setupForPathAuthoritative(string $path, bool $includeChildren =
525526
$rootIds = array_map(fn (ICachedMountInfo $info) => $info->getRootId(), $mountInfos);
526527
$rootsMetadata = $this->fileMetadataCache->getByFileIds($rootIds);
527528

528-
/** @var array<class-string<IMountProvider>, ICacheEntry[]> $rootsMetadataByProvider */
529-
$rootsMetadataByProvider = [];
530-
/** @var array<class-string<IMountProvider>, ICachedMountInfo[]> $mountInfosByProvider */
531-
$mountInfosByProvider = [];
529+
$argsByProvider = [];
532530
foreach ($mountInfos as $mountInfo) {
533531
$rootMetadata = $rootsMetadata[$mountInfo->getRootId()];
534-
/** @var class-string<IMountProvider> $mountProvider */
532+
/** @var class-string<IMountProvider>|'' $mountProvider */
535533
$mountProvider = $mountInfo->getMountProvider();
534+
if ($mountProvider === '') {
535+
// todo: which exception to throw? Do we need i8n?
536+
throw new \InvalidArgumentException('No mount provider found for mount-point');
537+
}
536538
if ($rootMetadata !== null) {
537-
$rootsMetadataByProvider[$mountProvider][]
538-
= $rootMetadata;
539+
$providerArgs = new IMountProviderArgs($mountInfo, $rootMetadata);
540+
$argsByProvider[$mountProvider][] = $providerArgs;
539541
}
540-
$mountInfosByProvider[$mountProvider][] = $mountInfo;
541542
}
542543

543544
$this->oneTimeUserSetup($user);
@@ -547,8 +548,7 @@ public function setupForPathAuthoritative(string $path, bool $includeChildren =
547548
$mounts = $this->getMountsFromProviders(
548549
$user,
549550
$path,
550-
$mountInfosByProvider,
551-
$rootsMetadataByProvider,
551+
$argsByProvider,
552552
);
553553

554554
if (!empty($mounts)) {
@@ -705,22 +705,20 @@ private function registerMounts(IUser $user, array $mounts, ?array $mountProvide
705705
* Returns mounts relevant to $path for the given $user, based on the
706706
* metadata provided.
707707
*
708-
* @param array<class-string<IMountProvider>, ICacheEntry[]> $rootsMetadataByProvider
709-
* @param array<class-string<IMountProvider>, ICachedMountInfo[]> $mountInfosByProvider
708+
* @param array<class-string<IMountProvider>, IMountProviderArgs[]> $mountArgsByProvider
710709
*
711710
* @return IMountPoint[]
712711
*/
713712
public function getMountsFromProviders(
714713
IUser $user,
715714
string $path,
716-
array $mountInfosByProvider,
717-
array $rootsMetadataByProvider,
715+
array $mountArgsByProvider,
718716
): array {
719717
$mounts = [];
720718
$userUid = $user->getUID();
721719
$this->setupUserMountProviders[$userUid] ??= [];
722720
/** @var class-string<IMountProvider> $providerClass */
723-
foreach ($mountInfosByProvider as $providerClass => $mountsInfos) {
721+
foreach ($mountArgsByProvider as $providerClass => $providerArgs) {
724722
if (in_array($providerClass, $this->setupUserMountProviders[$userUid])) {
725723
continue; // skip already setup providers
726724
}
@@ -732,8 +730,7 @@ public function getMountsFromProviders(
732730
->getUserMountsFromProviderByPath(
733731
$providerClass,
734732
$path,
735-
$mountsInfos,
736-
$rootsMetadataByProvider[$providerClass]
733+
$providerArgs,
737734
);
738735
} elseif (is_a($providerClass, IMountProvider::class, true)) {
739736
$this->setupUserMountProviders[$userUid] = $providerClass;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
namespace OCP\Files\Config;
10+
11+
use OCP\Files\Cache\ICacheEntry;
12+
13+
class IMountProviderArgs {
14+
public function __construct(
15+
public ICachedMountInfo $mountInfo,
16+
public ICacheEntry $cacheEntry,
17+
) {
18+
}
19+
}

lib/public/Files/Config/IPartialMountProvider.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
namespace OCP\Files\Config;
1010

11-
use OCP\Files\Cache\ICacheEntry;
1211
use OCP\Files\Mount\IMountPoint;
1312
use OCP\Files\Storage\IStorageFactory;
1413

@@ -19,15 +18,21 @@
1918
interface IPartialMountProvider extends IMountProvider {
2019

2120
/**
22-
* todo: $mountInfo may need to be an array of paths (string[])
23-
* @param ICachedMountInfo[] $mountsInfo
24-
* @param ICacheEntry[] $mountsMetadata
25-
* @return IMountPoint[]
21+
* Given the path for which mounts need to be set up, and an array of
22+
* IMountProviderArgs that provide information for the mount point and the
23+
* root of the mount, implementations of this function should return
24+
* IMountPoint instances after validating that the provided information
25+
* is still accurate.
26+
*
27+
* @param string $path path for which the mounts are setup
28+
* @param IMountProviderArgs[] $mountProviderArgs
29+
* @param IStorageFactory $loader
30+
* @return array<string, IMountPoint> IMountPoint instances, indexed by
31+
* mount-point
2632
*/
2733
public function getMountsFromMountPoints(
2834
string $path,
29-
array $mountsInfo,
30-
array $mountsMetadata,
31-
IStorageFactory $loader
35+
array $mountProviderArgs,
36+
IStorageFactory $loader,
3237
): array;
3338
}

0 commit comments

Comments
 (0)