From dc0dcad920f4e6e4723db3894915be91f8b75b28 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 15 Aug 2022 11:53:54 +0200 Subject: [PATCH 1/2] fix updating cached mounts that didn't have their mount provider set previously Signed-off-by: Robin Appelman --- lib/private/Files/Config/UserMountCache.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 666ba9b065b28..84e87c48bc782 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -104,7 +104,12 @@ public function registerMounts(IUser $user, array $mounts, array $mountProviderC $cachedMounts = $this->getMountsForUser($user); if (is_array($mountProviderClasses)) { - $cachedMounts = array_filter($cachedMounts, function (ICachedMountInfo $mountInfo) use ($mountProviderClasses) { + $cachedMounts = array_filter($cachedMounts, function (ICachedMountInfo $mountInfo) use ($mountProviderClasses, $newMounts) { + // for existing mounts that didn't have a mount provider set + // we still want the ones that map to new mounts + if ($mountInfo->getMountProvider() === '' && isset($newMounts[$mountInfo->getRootId()])) { + return true; + } return in_array($mountInfo->getMountProvider(), $mountProviderClasses); }); } From 82b915e7bbc6faf796b344c5afc84146a574f06e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 15 Aug 2022 12:45:41 +0200 Subject: [PATCH 2/2] add tests for cached mount provider migration Signed-off-by: Robin Appelman --- tests/lib/Files/Config/UserMountCacheTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php index f4c6a427abd49..c4f9688f3b290 100644 --- a/tests/lib/Files/Config/UserMountCacheTest.php +++ b/tests/lib/Files/Config/UserMountCacheTest.php @@ -506,4 +506,29 @@ public function testGetUsedSpaceForUsers() { $result = $this->cache->getUsedSpaceForUsers([$user1, $user2]); $this->assertEquals(['u1' => 100], $result); } + + + public function testMigrateMountProvider() { + $user1 = $this->userManager->get('u1'); + + [$storage1, $rootId] = $this->getStorage(2); + $rootId = $this->createCacheEntry('', 2); + $mount1 = new MountPoint($storage1, '/foo/'); + $this->cache->registerMounts($user1, [$mount1]); + + $this->clearCache(); + + $cachedMounts = $this->cache->getMountsForUser($user1); + $this->assertCount(1, $cachedMounts); + $this->assertEquals('', $cachedMounts[0]->getMountProvider()); + + $mount1 = new MountPoint($storage1, '/foo/', null, null, null, null, 'dummy'); + $this->cache->registerMounts($user1, [$mount1], ['dummy']); + + $this->clearCache(); + + $cachedMounts = $this->cache->getMountsForUser($user1); + $this->assertCount(1, $cachedMounts); + $this->assertEquals('dummy', $cachedMounts[0]->getMountProvider()); + } }