Codebase list cinnamon-menus / 40d4eaa
Follow-up to previous commit - retry only those desktop files that failed because of appinfo problems. Michael Webster 7 years ago
3 changed file(s) with 53 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
262262 return TRUE;
263263 }
264264
265 static gboolean
265 static DesktopEntryResultCode
266266 desktop_entry_load (DesktopEntry *entry)
267267 {
268268 if (strstr (entry->path, "/menu-xdg/"))
269 return FALSE;
269 return DESKTOP_ENTRY_LOAD_FAIL_OTHER;
270270 if (entry->type == DESKTOP_ENTRY_DESKTOP)
271271 {
272272 GKeyFile *key_file = NULL;
279279 !g_app_info_get_executable (G_APP_INFO (entry_desktop->appinfo)))
280280 {
281281 menu_verbose ("Failed to load \"%s\"\n", entry->path);
282 return FALSE;
282 return DESKTOP_ENTRY_LOAD_FAIL_APPINFO;
283283 }
284284
285285 categories_str = g_desktop_app_info_get_categories (entry_desktop->appinfo);
306306
307307 g_key_file_free (key_file);
308308
309 return TRUE;
309 return DESKTOP_ENTRY_LOAD_SUCCESS;
310310 }
311311 else if (entry->type == DESKTOP_ENTRY_DIRECTORY)
312312 {
313313 GKeyFile *key_file = NULL;
314314 GError *error = NULL;
315 gboolean retval = FALSE;
315 DesktopEntryResultCode rescode = DESKTOP_ENTRY_LOAD_SUCCESS;
316316
317317 key_file = g_key_file_new ();
318318
319319 if (!g_key_file_load_from_file (key_file, entry->path, 0, &error))
320 goto out;
320 {
321 rescode = DESKTOP_ENTRY_LOAD_FAIL_OTHER;
322 goto out;
323 }
321324
322325 if (!desktop_entry_load_directory (entry, key_file, &error))
323 goto out;
324
325 retval = TRUE;
326 {
327 rescode = DESKTOP_ENTRY_LOAD_FAIL_OTHER;
328 goto out;
329 }
330
331 rescode = DESKTOP_ENTRY_LOAD_SUCCESS;
326332
327333 out:
328334 g_key_file_free (key_file);
329335
330 if (!retval)
336 if (rescode == DESKTOP_ENTRY_LOAD_FAIL_OTHER)
331337 {
332338 if (error)
333339 {
338344 menu_verbose ("Failed to load \"%s\"\n", entry->path);
339345 }
340346
341 return retval;
347 return rescode;
342348 }
343349 else
344350 g_assert_not_reached ();
345351
346 return FALSE;
352 return DESKTOP_ENTRY_LOAD_FAIL_OTHER;
353 }
354
355 static gboolean
356 code_failed (DesktopEntryResultCode code)
357 {
358 return code == DESKTOP_ENTRY_LOAD_FAIL_OTHER ||
359 code == DESKTOP_ENTRY_LOAD_FAIL_APPINFO;
347360 }
348361
349362 DesktopEntry *
350 desktop_entry_new (const char *path)
363 desktop_entry_new (const char *path,
364 DesktopEntryResultCode *res_code)
351365 {
352366 DesktopEntryType type;
353367 DesktopEntry *retval;
368 DesktopEntryResultCode code;
354369
355370 menu_verbose ("Loading desktop entry \"%s\"\n", path);
356371
368383 {
369384 menu_verbose ("Unknown desktop entry suffix in \"%s\"\n",
370385 path);
386 *res_code = DESKTOP_ENTRY_LOAD_FAIL_OTHER;
371387 return NULL;
372388 }
373389
376392 retval->path = g_strdup (path);
377393 retval->basename = unix_basename_from_path (retval->path);
378394
379 if (!desktop_entry_load (retval))
395 code = desktop_entry_load (retval);
396 *res_code = code;
397
398 if (code_failed (code))
380399 {
381400 desktop_entry_unref (retval);
382401 return NULL;
418437 else
419438 g_assert_not_reached ();
420439
421 if (!desktop_entry_load (entry))
440 if (code_failed (desktop_entry_load (entry)))
422441 {
423442 desktop_entry_unref (entry);
424443 return NULL;
3030 DESKTOP_ENTRY_DIRECTORY
3131 } DesktopEntryType;
3232
33 typedef enum
34 {
35 DESKTOP_ENTRY_LOAD_SUCCESS = 0,
36 DESKTOP_ENTRY_LOAD_FAIL_OTHER,
37 DESKTOP_ENTRY_LOAD_FAIL_APPINFO
38 } DesktopEntryResultCode;
39
3340 typedef struct DesktopEntry DesktopEntry;
3441
35 DesktopEntry *desktop_entry_new (const char *path);
42 DesktopEntry *desktop_entry_new (const char *path,
43 DesktopEntryResultCode *res_code);
3644
3745 DesktopEntry *desktop_entry_ref (DesktopEntry *entry);
3846 DesktopEntry *desktop_entry_copy (DesktopEntry *entry);
317317 const char *path)
318318 {
319319 DesktopEntry *entry;
320
321 entry = desktop_entry_new (path);
320 DesktopEntryResultCode code;
321
322 entry = desktop_entry_new (path, &code);
322323 if (entry == NULL)
323324 {
324 menu_verbose ("Adding %s to the retry list (mimeinfo.cache maybe isn't done getting updated yet\n", path);
325
326 dir->retry_later_desktop_entries = g_slist_prepend (dir->retry_later_desktop_entries, g_strdup (path));
325 if (code == DESKTOP_ENTRY_LOAD_FAIL_APPINFO)
326 {
327 menu_verbose ("Adding %s to the retry list (mimeinfo.cache maybe isn't done getting updated yet\n", path);
328
329 dir->retry_later_desktop_entries = g_slist_prepend (dir->retry_later_desktop_entries, g_strdup (path));
330 }
331
327332 return FALSE;
328333 }
329334