4040use OCP \Constants ;
4141use OCP \Diagnostics \IEventLogger ;
4242use OCP \EventDispatcher \IEventDispatcher ;
43+ use OCP \Files \Config \ICachedMountInfo ;
4344use OCP \Files \Config \IHomeMountProvider ;
4445use OCP \Files \Config \IMountProvider ;
4546use OCP \Files \Config \IUserMountCache ;
@@ -414,9 +415,9 @@ public function setupForPath(string $path, bool $includeChildren = false): void
414415
415416 $ mounts = [];
416417 if (!in_array ($ cachedMount ->getMountProvider (), $ setupProviders )) {
417- $ setupProviders [] = $ cachedMount ->getMountProvider ();
418418 $ currentProviders [] = $ cachedMount ->getMountProvider ();
419419 if ($ cachedMount ->getMountProvider ()) {
420+ $ setupProviders [] = $ cachedMount ->getMountProvider ();
420421 $ mounts = $ this ->mountProviderCollection ->getUserMountsForProviderClasses ($ user , [$ cachedMount ->getMountProvider ()]);
421422 } else {
422423 $ this ->logger ->debug ("mount at " . $ cachedMount ->getMountPoint () . " has no provider set, performing full setup " );
@@ -427,16 +428,21 @@ public function setupForPath(string $path, bool $includeChildren = false): void
427428
428429 if ($ includeChildren ) {
429430 $ subCachedMounts = $ this ->userMountCache ->getMountsInPath ($ user , $ path );
430- foreach ($ subCachedMounts as $ cachedMount ) {
431- if (!in_array ($ cachedMount ->getMountProvider (), $ setupProviders )) {
432- $ setupProviders [] = $ cachedMount ->getMountProvider ();
433- $ currentProviders [] = $ cachedMount ->getMountProvider ();
434- if ($ cachedMount ->getMountProvider ()) {
431+
432+ $ needsFullSetup = array_reduce ($ subCachedMounts , function (bool $ needsFullSetup , ICachedMountInfo $ cachedMountInfo ) {
433+ return $ needsFullSetup || $ cachedMountInfo ->getMountProvider () === '' ;
434+ }, false );
435+
436+ if ($ needsFullSetup ) {
437+ $ this ->logger ->debug ("mount has no provider set, performing full setup " );
438+ $ this ->setupForUser ($ user );
439+ return ;
440+ } else {
441+ foreach ($ subCachedMounts as $ cachedMount ) {
442+ if (!in_array ($ cachedMount ->getMountProvider (), $ setupProviders )) {
443+ $ currentProviders [] = $ cachedMount ->getMountProvider ();
444+ $ setupProviders [] = $ cachedMount ->getMountProvider ();
435445 $ mounts = array_merge ($ mounts , $ this ->mountProviderCollection ->getUserMountsForProviderClasses ($ user , [$ cachedMount ->getMountProvider ()]));
436- } else {
437- $ this ->logger ->debug ("mount at " . $ cachedMount ->getMountPoint () . " has no provider set, performing full setup " );
438- $ this ->setupForUser ($ user );
439- return ;
440446 }
441447 }
442448 }
0 commit comments