@@ -90,7 +90,6 @@ void CacheManagerDelete( CacheManager *cm )
9090 FFree ( cm -> cm_CacheFileGroup );
9191 }
9292
93- CacheUserFilesDeleteAll ( cm -> cm_CacheUserFiles );
9493 /*
9594 LocFile *lf = cm->cm_LocFileCache;
9695 while( lf != NULL )
@@ -208,42 +207,19 @@ int CacheManagerFilePut( CacheManager *cm, LocFile *lf )
208207/**
209208 * function store LocFile inside cache (User cache)
210209 *
211- * @param cm pointer to CacheManager which will store file
212- * @param usr pointer to User structure
210+ * @param locusr pointer to User structure
213211 * @param lf pointer to LocFile structure which will be stored in cache
214212 * @return 0 when success, otherwise error number
215213 */
216- int CacheManagerUserFilePut ( CacheManager * cm , void * usr , LocFile * lf )
214+ int CacheManagerUserFilePut ( void * locusr , LocFile * lf )
217215{
218- if ( cm != NULL )
216+ if ( locusr != NULL )
219217 {
220218 // trying to find user assigned to CacheUserFiles, on the end we should assign cache to user
221- CacheUserFiles * cusf = cm -> cm_CacheUserFiles ;
222- while ( cusf != NULL )
223- {
224- if ( cusf -> cuf_Usr == usr )
225- {
226- break ;
227- }
228- cusf = (CacheUserFiles * )cusf -> node .mln_Succ ;
229- }
230-
231- // if CacheUserFiles exist, we are adding file to list
232- if ( cusf != NULL )
233- {
234- CacheUserFilesAddFile ( cusf , lf );
235- }
236- else
237- {
238- CacheUserFiles * newcuf = CacheUserFilesNew ( usr );
239- if ( newcuf != NULL )
240- {
241- newcuf -> node .mln_Succ = (MinNode * )cm -> cm_CacheUserFiles ;
242- cm -> cm_CacheUserFiles = newcuf ;
243-
244- CacheUserFilesAddFile ( newcuf , lf );
245- }
246- }
219+ User * usr = (User * )locusr ;
220+
221+ CacheUserFilesAddFile ( & (usr -> u_FileCache ), lf );
222+
247223 }
248224 return 0 ;
249225}
@@ -252,25 +228,16 @@ int CacheManagerUserFilePut( CacheManager *cm, void *usr, LocFile *lf )
252228/**
253229 * function get LocFile from cache (User cache)
254230 *
255- * @param cm pointer to CacheManager where LocFile will be searched
256- * @param usr pointer to User structure
231+ * @param locusr pointer to User structure
257232 * @param path full path to file (include device name)
258233 * @return LocFile structure when success, otherwise NULL
259234 */
260- LocFile * CacheManagerUserFileGet ( CacheManager * cm , void * usr , char * path )
235+ LocFile * CacheManagerUserFileGet ( void * locusr , char * path )
261236{
262- if ( cm != NULL )
237+ if ( locusr != NULL )
263238 {
264239 // trying to find user assigned to CacheUserFiles, on the end we should assign cache to user
265- CacheUserFiles * cusf = cm -> cm_CacheUserFiles ;
266- while ( cusf != NULL )
267- {
268- if ( cusf -> cuf_Usr == usr )
269- {
270- break ;
271- }
272- cusf = (CacheUserFiles * )cusf -> node .mln_Succ ;
273- }
240+ User * usr = (User * )locusr ;
274241
275242 uint64_t hash [ 2 ];
276243 MURMURHASH3 ( path , strlen (path ), hash );
@@ -279,18 +246,16 @@ LocFile *CacheManagerUserFileGet( CacheManager *cm, void *usr, char *path )
279246 unsigned char id = (unsigned char )hfirstChar [0 ];
280247
281248 // if CacheUserFiles exist, we are trying to find file
282- if ( cusf != NULL )
249+
250+ LocFile * lf = usr -> u_FileCache -> cuf_File ;
251+ while ( lf != NULL )
283252 {
284- LocFile * lf = cusf -> cuf_File ;
285- while ( lf != NULL )
253+ if ( memcmp ( hash , lf -> hash , sizeof (hash ) ) == 0 )
286254 {
287- if ( memcmp ( hash , lf -> hash , sizeof (hash ) ) == 0 )
288- {
289- lf -> lf_FileUsed ++ ;
290- return lf ;
291- }
292- lf = (LocFile * )lf -> node .mln_Succ ;
255+ lf -> lf_FileUsed ++ ;
256+ return lf ;
293257 }
258+ lf = (LocFile * )lf -> node .mln_Succ ;
294259 }
295260 }
296261 return 0 ;
0 commit comments