99
1010use  OC \User \LazyUser ;
1111use  OCP \Cache \CappedMemoryCache ;
12+ use  OCP \DB \IResult ;
1213use  OCP \DB \QueryBuilder \IQueryBuilder ;
1314use  OCP \Diagnostics \IEventLogger ;
1415use  OCP \Files \Config \ICachedMountFileInfo ;
@@ -190,6 +191,19 @@ private function removeFromCache(ICachedMountInfo $mount) {
190191		$ queryexecute ();
191192	}
192193
194+ 	/** 
195+ 	 * @param IResult $result 
196+ 	 * @return CachedMountInfo[] 
197+ 	 */ 
198+ 	private  function  fetchMountInfo (IResult $ resultcallable  $ pathCallbacknull ): array  {
199+ 		$ mounts
200+ 		while  ($ row$ resultfetch ()) {
201+ 			$ mount$ this dbRowToMountInfo ($ row$ pathCallback
202+ 			$ mounts$ mount
203+ 		}
204+ 		return  array_filter ($ mounts
205+ 	}
206+ 
193207	/** 
194208	 * @param array $row 
195209	 * @param (callable(CachedMountInfo): string)|null $pathCallback 
@@ -239,19 +253,11 @@ public function getMountsForUser(IUser $user) {
239253				->from ('mounts ' , 'm ' )
240254				->where ($ builderexpr ()->eq ('user_id ' , $ buildercreateNamedParameter ($ userUID
241255
242- 			$ result$ queryexecute ();
243- 			$ rows$ resultfetchAll ();
244- 			$ resultcloseCursor ();
245- 
246- 			/** @var array<string, ICachedMountInfo> $mounts */ 
247- 			$ mounts
248- 			foreach  ($ rowsas  $ row
249- 				$ mount$ this dbRowToMountInfo ($ row$ this 'getInternalPathForMountInfo ' ]);
250- 				if  ($ mountnull ) {
251- 					$ mounts$ mountgetKey ()] = $ mount
252- 				}
253- 			}
254- 			$ this mountsForUsers [$ userUID$ mounts
256+ 			$ mounts$ this fetchMountInfo ($ queryexecute (), [$ this 'getInternalPathForMountInfo ' ]);
257+ 			$ keysarray_map (function (ICachedMountInfo $ mount
258+ 				return  $ mountgetKey ();
259+ 			}, $ mounts
260+ 			$ this mountsForUsers [$ userUIDarray_combine ($ keys$ mounts
255261		}
256262		return  $ this mountsForUsers [$ userUID
257263	}
@@ -284,11 +290,7 @@ public function getMountsForStorageId($numericStorageId, $user = null) {
284290			$ queryandWhere ($ builderexpr ()->eq ('user_id ' , $ buildercreateNamedParameter ($ user
285291		}
286292
287- 		$ result$ queryexecute ();
288- 		$ rows$ resultfetchAll ();
289- 		$ resultcloseCursor ();
290- 
291- 		return  array_filter (array_map ([$ this 'dbRowToMountInfo ' ], $ rows
293+ 		return  $ this fetchMountInfo ($ queryexecuteQuery ());
292294	}
293295
294296	/** 
@@ -302,11 +304,7 @@ public function getMountsForRootId($rootFileId) {
302304			->innerJoin ('m ' , 'filecache ' , 'f ' , $ builderexpr ()->eq ('m.root_id ' , 'f.fileid ' ))
303305			->where ($ builderexpr ()->eq ('root_id ' , $ buildercreateNamedParameter ($ rootFileIdPARAM_INT )));
304306
305- 		$ result$ queryexecute ();
306- 		$ rows$ resultfetchAll ();
307- 		$ resultcloseCursor ();
308- 
309- 		return  array_filter (array_map ([$ this 'dbRowToMountInfo ' ], $ rows
307+ 		return  $ this fetchMountInfo ($ queryexecuteQuery ());
310308	}
311309
312310	/** 
0 commit comments