2626 * along with this program. If not, see <http://www.gnu.org/licenses/>
2727 *
2828 */
29+
2930namespace OC \Files \Config ;
3031
3132use OC \Cache \CappedMemoryCache ;
@@ -56,12 +57,7 @@ class UserMountCache implements IUserMountCache {
5657 */
5758 private $ userManager ;
5859
59- /**
60- * Cached mount info.
61- * Map of $userId to ICachedMountInfo.
62- *
63- * @var ICache
64- **/
60+ /** @var CappedMemoryCache<ICachedMountInfo[]> */
6561 private $ mountsForUsers ;
6662
6763 private LoggerInterface $ logger ;
@@ -104,7 +100,9 @@ public function registerMounts(IUser $user, array $mounts, array $mountProviderC
104100
105101 $ cachedMounts = $ this ->getMountsForUser ($ user );
106102 if (is_array ($ mountProviderClasses )) {
107- $ cachedMounts = array_filter ($ cachedMounts , function (ICachedMountInfo $ mountInfo ) use ($ mountProviderClasses ) {
103+ $ cachedMounts = array_filter ($ cachedMounts , function (ICachedMountInfo $ mountInfo ) use (
104+ $ mountProviderClasses
105+ ) {
108106 return in_array ($ mountInfo ->getMountProvider (), $ mountProviderClasses );
109107 });
110108 }
@@ -113,7 +111,9 @@ public function registerMounts(IUser $user, array $mounts, array $mountProviderC
113111 }, $ cachedMounts );
114112 $ cachedMounts = array_combine ($ cachedMountRootIds , $ cachedMounts );
115113
114+ /** @var ICachedMountInfo[] $addedMounts */
116115 $ addedMounts = [];
116+ /** @var ICachedMountInfo[] $removedMounts */
117117 $ removedMounts = [];
118118
119119 foreach ($ newMounts as $ rootId => $ newMount ) {
@@ -136,8 +136,13 @@ public function registerMounts(IUser $user, array $mounts, array $mountProviderC
136136 }
137137 foreach ($ removedMounts as $ mount ) {
138138 $ this ->removeFromCache ($ mount );
139- $ index = array_search ($ mount , $ this ->mountsForUsers [$ user ->getUID ()]);
140- unset($ this ->mountsForUsers [$ user ->getUID ()][$ index ]);
139+ foreach ($ this ->mountsForUsers [$ user ->getUID ()] as $ index => $ mountForUser ) {
140+ /** @var ICachedMountInfo $mountForUser */
141+ if ($ mount ->getRootId () == $ mountForUser ->getRootId () && $ mount ->getMountPoint () == $ mountForUser ->getMountPoint ()) {
142+ unset($ this ->mountsForUsers [$ user ->getUID ()][$ index ]);
143+ break ;
144+ }
145+ }
141146 }
142147 foreach ($ changedMounts as $ mount ) {
143148 $ this ->updateCachedMount ($ mount );
@@ -313,7 +318,7 @@ private function getCacheInfoFromFileId($fileId): array {
313318 $ this ->cacheInfoCache [$ fileId ] = [
314319 (int )$ row ['storage ' ],
315320 (string )$ row ['path ' ],
316- (int )$ row ['mimetype ' ]
321+ (int )$ row ['mimetype ' ],
317322 ];
318323 } else {
319324 throw new NotFoundException ('File with id " ' . $ fileId . '" not found ' );
0 commit comments