diff options
-rw-r--r-- | lib/private/Files/Config/UserMountCache.php | 7 | ||||
-rw-r--r-- | tests/lib/Files/Config/UserMountCacheTest.php | 25 |
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 685057a7860..3540b563742 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -90,7 +90,12 @@ class UserMountCache implements IUserMountCache { $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); }); } diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php index 8b26b309daa..f1206781c5e 100644 --- a/tests/lib/Files/Config/UserMountCacheTest.php +++ b/tests/lib/Files/Config/UserMountCacheTest.php @@ -507,4 +507,29 @@ class UserMountCacheTest extends TestCase { $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()); + } } |