[gnome-software/mwleeds/hardcoded-pwa-list] epiphany: Change how we handle an error listing apps
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/mwleeds/hardcoded-pwa-list] epiphany: Change how we handle an error listing apps
- Date: Mon, 16 May 2022 21:46:29 +0000 (UTC)
commit 7fc3fbd14042b2259c40e11bf8d90a80f9b7ed84
Author: Phaedrus Leeds <mwleeds protonmail com>
Date: Mon May 16 14:41:27 2022 -0700
epiphany: Change how we handle an error listing apps
Currently, if the org.gnome.Epiphany.WebAppProvider.GetInstalledApps()
D-Bus method returns an error, ensure_installed_apps_cache() returns
FALSE, and in case the caller is gs_epiphany_refine_app_state(), this
leads to a warning being printed. Then, refine_thread_cb() would call
gs_epiphany_refine_app_state() -> ensure_installed_apps_cache() for each
remaining app being refined, and in all likelihood we would encounter
the same error n times.
Change things so that we call ensure_installed_apps_cache() once in
refine_thread_cb(), and any error from it causes the task to fail, which
makes more sense and is consistent with the behavior of
list_installed_apps_thread_cb().
plugins/epiphany/gs-plugin-epiphany.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index dabb78b91..51c073aa2 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -337,7 +337,7 @@ static gboolean ensure_installed_apps_cache (GsPluginEpiphany *self,
GCancellable *cancellable,
GError **error);
-/* Run in @worker */
+/* Run in @worker. The caller must have already done ensure_installed_apps_cache() */
static void
gs_epiphany_refine_app_state (GsPlugin *plugin,
GsApp *app)
@@ -348,14 +348,8 @@ gs_epiphany_refine_app_state (GsPlugin *plugin,
if (gs_app_get_state (app) == GS_APP_STATE_UNKNOWN) {
g_autoptr(GsApp) cached_app = NULL;
- g_autoptr(GError) local_error = NULL;
const char *appstream_source;
- if (!ensure_installed_apps_cache (self, NULL, &local_error)) {
- g_warning ("Failed to refresh installed apps cache: %s", local_error->message);
- return;
- }
-
/* If we have a cached app, set the state from there. Otherwise
* only set the state to available if the app came from
* appstream data, because there's no way to re-install an app
@@ -806,6 +800,11 @@ refine_thread_cb (GTask *task,
assert_in_worker (self);
+ if (!ensure_installed_apps_cache (self, cancellable, &local_error)) {
+ g_task_return_error (task, g_steal_pointer (&local_error));
+ return;
+ }
+
for (guint i = 0; i < gs_app_list_length (list); i++) {
GsApp *app = gs_app_list_index (list, i);
const char *url;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]