[gnome-software: 53/72] flatpak: Move refine_wildcard into refine
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 53/72] flatpak: Move refine_wildcard into refine
- Date: Wed, 15 Dec 2021 13:00:56 +0000 (UTC)
commit ddd9f78cad483b5a6aa58583905574c3a6c5be84
Author: Philip Withnall <pwithnall endlessos org>
Date: Mon Nov 22 18:48:29 2021 +0000
flatpak: Move refine_wildcard into refine
It’s confusing and complicates the plugin and plugin loader code to have
`refine` and `refine_wildcard` both called by `ACTION_REFINE`. It
simplifies things to have plugins implement `refine_wildcard` inside
`refine` themselves where needed. Only 3 plugins are actually affected.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
plugins/flatpak/gs-plugin-flatpak.c | 46 +++++++++++++++++++++----------------
1 file changed, 26 insertions(+), 20 deletions(-)
---
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 2a0d1eeea..de3ccf227 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -532,6 +532,7 @@ refine_thread_cb (GTask *task,
GsPluginRefineData *data = task_data;
GsAppList *list = data->list;
GsPluginRefineFlags flags = data->flags;
+ g_autoptr(GsAppList) app_list = NULL;
g_autoptr(GError) local_error = NULL;
assert_in_worker (self);
@@ -544,6 +545,31 @@ refine_thread_cb (GTask *task,
}
}
+ /* Refine wildcards.
+ *
+ * Use a copy of the list for the loop because a function called
+ * on the plugin may affect the list which can lead to problems
+ * (e.g. inserting an app in the list on every call results in
+ * an infinite loop) */
+ app_list = gs_app_list_copy (list);
+
+ for (guint j = 0; j < gs_app_list_length (app_list); j++) {
+ GsApp *app = gs_app_list_index (app_list, j);
+
+ if (!gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
+ continue;
+
+ for (guint i = 0; i < self->installations->len; i++) {
+ GsFlatpak *flatpak = g_ptr_array_index (self->installations, i);
+
+ if (!gs_flatpak_refine_wildcard (flatpak, app, list, flags,
+ cancellable, &local_error)) {
+ g_task_return_error (task, g_steal_pointer (&local_error));
+ return;
+ }
+ }
+ }
+
g_task_return_boolean (task, TRUE);
}
@@ -555,26 +581,6 @@ gs_plugin_flatpak_refine_finish (GsPlugin *plugin,
return g_task_propagate_boolean (G_TASK (result), error);
}
-gboolean
-gs_plugin_refine_wildcard (GsPlugin *plugin,
- GsApp *app,
- GsAppList *list,
- GsPluginRefineFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GsPluginFlatpak *self = GS_PLUGIN_FLATPAK (plugin);
-
- for (guint i = 0; i < self->installations->len; i++) {
- GsFlatpak *flatpak = g_ptr_array_index (self->installations, i);
- if (!gs_flatpak_refine_wildcard (flatpak, app, list, flags,
- cancellable, error)) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
gboolean
gs_plugin_launch (GsPlugin *plugin,
GsApp *app,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]