[gnome-software/wip/mcrha/flatpak-appstream-update] flatpak: Update remote appstream data when its filter changed
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/mcrha/flatpak-appstream-update] flatpak: Update remote appstream data when its filter changed
- Date: Thu, 7 Oct 2021 17:31:17 +0000 (UTC)
commit 1a32bd3eaaf7ec0322c46599e3b949080a410806
Author: Milan Crha <mcrha redhat com>
Date: Thu Oct 7 19:28:38 2021 +0200
flatpak: Update remote appstream data when its filter changed
When overwriting existing remote, make sure the appstream data is updated
as well when the filter changed, to have shown relevant applications.
Related to https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1453
plugins/flatpak/gs-flatpak.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index bd87d57ed..88bb69a72 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -1623,6 +1623,9 @@ gs_flatpak_app_install_source (GsFlatpak *self,
GError **error)
{
g_autoptr(FlatpakRemote) xremote = NULL;
+ #if FLATPAK_CHECK_VERSION(1, 4, 0)
+ gboolean filter_changed = FALSE;
+ #endif
xremote = flatpak_installation_get_remote_by_name (self->installation,
gs_app_get_id (app),
@@ -1632,11 +1635,13 @@ gs_flatpak_app_install_source (GsFlatpak *self,
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_title (xremote, gs_app_get_origin_ui (app));
#if FLATPAK_CHECK_VERSION(1, 4, 0)
+ g_autofree gchar *current_filter = flatpak_remote_get_filter (xremote);
+ filter_changed = g_strcmp0 (current_filter, gs_flatpak_app_get_repo_filter (app)) !=
0;
flatpak_remote_set_filter (xremote, gs_flatpak_app_get_repo_filter (app));
flatpak_remote_set_description (xremote, gs_app_get_description (app));
#endif
+ flatpak_remote_set_title (xremote, gs_app_get_origin_ui (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));
@@ -1666,6 +1671,17 @@ gs_flatpak_app_install_source (GsFlatpak *self,
/* success */
gs_app_set_state (app, GS_APP_STATE_INSTALLED);
+ #if FLATPAK_CHECK_VERSION(1, 4, 0)
+ if (filter_changed) {
+ g_autoptr(GError) local_error = NULL;
+ const gchar *remote_name = flatpak_remote_get_name (xremote);
+ if (!flatpak_installation_update_appstream_sync (self->installation, remote_name, NULL, NULL,
cancellable, &local_error) &&
+ !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_warning ("Failed to update appstream data for flatpak remote '%s': %s",
+ remote_name, local_error->message);
+ }
+ }
+ #endif
gs_plugin_repository_changed (self->plugin, app);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]