@@ -92,38 +92,39 @@ public function registerMounts(IUser $user, array $mounts, array $mountProviderC
9292 }
9393 }, $ mounts );
9494 $ newMounts = array_values (array_filter ($ newMounts ));
95- $ newMountRootIds = array_map (function (ICachedMountInfo $ mount ) {
96- return $ mount ->getRootId ();
95+ $ newMountKeys = array_map (function (ICachedMountInfo $ mount ) {
96+ return $ mount ->getRootId () . ' :: ' . $ mount -> getMountPoint () ;
9797 }, $ newMounts );
98- $ newMounts = array_combine ($ newMountRootIds , $ newMounts );
98+ $ newMounts = array_combine ($ newMountKeys , $ newMounts );
9999
100100 $ cachedMounts = $ this ->getMountsForUser ($ user );
101101 if (is_array ($ mountProviderClasses )) {
102102 $ cachedMounts = array_filter ($ cachedMounts , function (ICachedMountInfo $ mountInfo ) use ($ mountProviderClasses , $ newMounts ) {
103103 // for existing mounts that didn't have a mount provider set
104104 // we still want the ones that map to new mounts
105- if ($ mountInfo ->getMountProvider () === '' && isset ($ newMounts [$ mountInfo ->getRootId ()])) {
105+ $ mountKey = $ mountInfo ->getRootId () . ':: ' . $ mountInfo ->getMountPoint ();
106+ if ($ mountInfo ->getMountProvider () === '' && isset ($ newMounts [$ mountKey ])) {
106107 return true ;
107108 }
108109 return in_array ($ mountInfo ->getMountProvider (), $ mountProviderClasses );
109110 });
110111 }
111- $ cachedMountRootIds = array_map (function (ICachedMountInfo $ mount ) {
112- return $ mount ->getRootId ();
112+ $ cachedRootKeys = array_map (function (ICachedMountInfo $ mount ) {
113+ return $ mount ->getRootId () . ' :: ' . $ mount -> getMountPoint () ;
113114 }, $ cachedMounts );
114- $ cachedMounts = array_combine ($ cachedMountRootIds , $ cachedMounts );
115+ $ cachedMounts = array_combine ($ cachedRootKeys , $ cachedMounts );
115116
116117 $ addedMounts = [];
117118 $ removedMounts = [];
118119
119- foreach ($ newMounts as $ rootId => $ newMount ) {
120- if (!isset ($ cachedMounts [$ rootId ])) {
120+ foreach ($ newMounts as $ mountKey => $ newMount ) {
121+ if (!isset ($ cachedMounts [$ mountKey ])) {
121122 $ addedMounts [] = $ newMount ;
122123 }
123124 }
124125
125- foreach ($ cachedMounts as $ rootId => $ cachedMount ) {
126- if (!isset ($ newMounts [$ rootId ])) {
126+ foreach ($ cachedMounts as $ mountKey => $ cachedMount ) {
127+ if (!isset ($ newMounts [$ mountKey ])) {
127128 $ removedMounts [] = $ cachedMount ;
128129 }
129130 }
@@ -161,13 +162,13 @@ public function registerMounts(IUser $user, array $mounts, array $mountProviderC
161162 private function findChangedMounts (array $ newMounts , array $ cachedMounts ) {
162163 $ new = [];
163164 foreach ($ newMounts as $ mount ) {
164- $ new [$ mount ->getRootId ()] = $ mount ;
165+ $ new [$ mount ->getRootId () . ' :: ' . $ mount -> getMountPoint () ] = $ mount ;
165166 }
166167 $ changed = [];
167168 foreach ($ cachedMounts as $ cachedMount ) {
168- $ rootId = $ cachedMount ->getRootId ();
169- if (isset ($ new [$ rootId ])) {
170- $ newMount = $ new [$ rootId ];
169+ $ key = $ cachedMount ->getRootId () . ' :: ' . $ cachedMount -> getMountPoint ();
170+ if (isset ($ new [$ key ])) {
171+ $ newMount = $ new [$ key ];
171172 if (
172173 $ newMount ->getMountPoint () !== $ cachedMount ->getMountPoint () ||
173174 $ newMount ->getStorageId () !== $ cachedMount ->getStorageId () ||
@@ -190,7 +191,7 @@ private function addToCache(ICachedMountInfo $mount) {
190191 'mount_point ' => $ mount ->getMountPoint (),
191192 'mount_id ' => $ mount ->getMountId (),
192193 'mount_provider_class ' => $ mount ->getMountProvider (),
193- ], ['root_id ' , 'user_id ' ]);
194+ ], ['root_id ' , 'user_id ' , ' mount_point ' ]);
194195 } else {
195196 // in some cases this is legitimate, like orphaned shares
196197 $ this ->logger ->debug ('Could not get storage info for mount at ' . $ mount ->getMountPoint ());
@@ -216,7 +217,8 @@ private function removeFromCache(ICachedMountInfo $mount) {
216217
217218 $ query = $ builder ->delete ('mounts ' )
218219 ->where ($ builder ->expr ()->eq ('user_id ' , $ builder ->createNamedParameter ($ mount ->getUser ()->getUID ())))
219- ->andWhere ($ builder ->expr ()->eq ('root_id ' , $ builder ->createNamedParameter ($ mount ->getRootId (), IQueryBuilder::PARAM_INT )));
220+ ->andWhere ($ builder ->expr ()->eq ('root_id ' , $ builder ->createNamedParameter ($ mount ->getRootId (), IQueryBuilder::PARAM_INT )))
221+ ->andWhere ($ builder ->expr ()->eq ('mount_point ' , $ builder ->createNamedParameter ($ mount ->getMountPoint ())));
220222 $ query ->execute ();
221223 }
222224
0 commit comments