[gnome-software: 5/7] flatpak: Update all properties when modifying existing remote
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 5/7] flatpak: Update all properties when modifying existing remote
- Date: Wed, 1 Dec 2021 13:16:45 +0000 (UTC)
commit 4b1205c1b18b6c0bf8d7473e7098bd81087a8231
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue Oct 19 12:27:26 2021 +0100
flatpak: Update all properties when modifying existing remote
When modifying an existing remote using a flatpakrepo file, update all
the existing properties from the file, not just the description, title
and filter.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1507
plugins/flatpak/gs-flatpak.c | 47 +++++++++++++++++++++++++++++++-------------
1 file changed, 33 insertions(+), 14 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 318154a58..f34d98a99 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -1550,21 +1550,19 @@ gs_flatpak_ref_to_app (GsFlatpak *self, const gchar *ref,
}
/* This is essentially the inverse of gs_flatpak_app_new_from_repo_file() */
-static FlatpakRemote *
-gs_flatpak_create_new_remote (GsFlatpak *self,
- GsApp *app,
- GCancellable *cancellable,
- GError **error)
+static void
+gs_flatpak_update_remote_from_app (GsFlatpak *self,
+ FlatpakRemote *xremote,
+ GsApp *app)
{
const gchar *gpg_key;
const gchar *branch;
const gchar *title, *homepage, *comment, *description;
const gchar *filter;
GPtrArray *icons;
- g_autoptr(FlatpakRemote) xremote = NULL;
- /* create a new remote */
- xremote = flatpak_remote_new (gs_app_get_id (app));
+ flatpak_remote_set_disabled (xremote, FALSE);
+
flatpak_remote_set_url (xremote, gs_flatpak_app_get_repo_url (app));
flatpak_remote_set_noenumerate (xremote, FALSE);
@@ -1615,13 +1613,34 @@ gs_flatpak_create_new_remote (GsFlatpak *self,
}
}
+ /* With the other fields, we always want to add as much information as
+ * we can to the @xremote. With the filter, though, we want to drop it
+ * if no filter is set on the @app. Importing an updated flatpakrepo
+ * file is one of the methods for switching from (for example) filtered
+ * flathub to unfiltered flathub. So if @app doesn’t have a filter set,
+ * clear it on the @xremote (i.e. don’t check for NULL). */
filter = gs_flatpak_app_get_repo_filter (app);
- if (filter != NULL)
- flatpak_remote_set_filter (xremote, filter);
+ flatpak_remote_set_filter (xremote, filter);
+}
+
+static FlatpakRemote *
+gs_flatpak_create_new_remote (GsFlatpak *self,
+ GsApp *app,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_autoptr(FlatpakRemote) xremote = NULL;
+
+ /* create a new remote */
+ xremote = flatpak_remote_new (gs_app_get_id (app));
+ gs_flatpak_update_remote_from_app (self, xremote, app);
return g_steal_pointer (&xremote);
}
+/* @is_install is %TRUE if the repo is being installed, or %FALSE if it’s being
+ * enabled. If it’s being enabled, no properties apart from enabled/disabled
+ * should be modified. */
gboolean
gs_flatpak_app_install_source (GsFlatpak *self,
GsApp *app,
@@ -1638,10 +1657,10 @@ gs_flatpak_app_install_source (GsFlatpak *self,
/* if the remote already exists, just enable it and update it */
g_debug ("modifying existing remote %s", flatpak_remote_get_name (xremote));
flatpak_remote_set_disabled (xremote, FALSE);
- if (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_REPO) {
- flatpak_remote_set_filter (xremote, gs_flatpak_app_get_repo_filter (app));
- flatpak_remote_set_description (xremote, gs_app_get_description (app));
- flatpak_remote_set_title (xremote, gs_app_get_origin_ui (app));
+
+ if (is_install &&
+ gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_REPO) {
+ gs_flatpak_update_remote_from_app (self, xremote, app);
}
} else if (!is_install) {
g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "Cannot enable flatpak remote
'%s', remote not found", gs_app_get_id (app));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]