File tree 1 file changed +23
-4
lines changed
1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -233,7 +233,13 @@ struct desktop_vec drun_generate_cached()
233
233
free (cache_path );
234
234
return apps ;
235
235
}
236
+ errno = 0 ;
236
237
FILE * cache = fopen (cache_path , "wb" );
238
+ if (cache == NULL ) {
239
+ log_error ("Error creating drun cache: %s.\n" , strerror (errno ));
240
+ free (cache_path );
241
+ return apps ;
242
+ }
237
243
desktop_vec_save (& apps , cache );
238
244
fclose (cache );
239
245
free (cache_path );
@@ -265,14 +271,27 @@ struct desktop_vec drun_generate_cached()
265
271
log_indent ();
266
272
apps = drun_generate ();
267
273
log_unindent ();
274
+ errno = 0 ;
268
275
FILE * cache = fopen (cache_path , "wb" );
269
- desktop_vec_save (& apps , cache );
270
- fclose (cache );
276
+ if (cache == NULL ) {
277
+ log_error ("Failed to update cache: %s.\n" , strerror (errno ));
278
+ } else {
279
+ desktop_vec_save (& apps , cache );
280
+ fclose (cache );
281
+ }
271
282
} else {
272
283
log_debug ("Cache up to date, loading.\n" );
284
+ errno = 0 ;
273
285
FILE * cache = fopen (cache_path , "rb" );
274
- apps = desktop_vec_load (cache );
275
- fclose (cache );
286
+ if (cache == NULL ) {
287
+ log_error ("Failed to load cache: %s.\n" , strerror (errno ));
288
+ log_indent ();
289
+ apps = drun_generate ();
290
+ log_unindent ();
291
+ } else {
292
+ apps = desktop_vec_load (cache );
293
+ fclose (cache );
294
+ }
276
295
}
277
296
free (cache_path );
278
297
return apps ;
You can’t perform that action at this time.
0 commit comments