[gnome-software/gnome-3-22] Backport misc flatpak fixes from master
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-22] Backport misc flatpak fixes from master
- Date: Tue, 7 Mar 2017 16:32:34 +0000 (UTC)
commit 4858a905ee1645e59132e1c73831a68a6a1ca19e
Author: Kalev Lember <klember redhat com>
Date: Tue Mar 7 16:18:16 2017 +0100
Backport misc flatpak fixes from master
This backports the actual fixes from commit 715e46a without the
associated self tests.
src/plugins/gs-appstream.c | 4 +++
src/plugins/gs-flatpak.c | 48 ++++++++++++++++++++++++++++++++++--
src/plugins/gs-plugin-appstream.c | 13 +++++++---
src/plugins/gs-plugin-flatpak.c | 3 ++
4 files changed, 61 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index ea24748..73c2db7 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -392,6 +392,10 @@ gs_appstream_refine_app_updates (GsPlugin *plugin,
GPtrArray *releases;
g_autoptr(GPtrArray) updates_list = NULL;
+ /* only for UPDATABLE apps */
+ if (!gs_app_is_updatable (app))
+ return TRUE;
+
/* make a list of valid updates */
updates_list = g_ptr_array_new ();
releases = as_app_get_releases (item);
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index fb19013..43a038b 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -43,6 +43,7 @@ struct _GsFlatpak {
AsAppScope scope;
GsPlugin *plugin;
AsStore *store;
+ guint changed_id;
};
G_DEFINE_TYPE (GsFlatpak, gs_flatpak, G_TYPE_OBJECT)
@@ -389,8 +390,9 @@ gs_flatpak_setup (GsFlatpak *self, GCancellable *cancellable, GError **error)
if (self->monitor == NULL) {
return FALSE;
}
- g_signal_connect (self->monitor, "changed",
- G_CALLBACK (gs_plugin_flatpak_changed_cb), self);
+ self->changed_id =
+ g_signal_connect (self->monitor, "changed",
+ G_CALLBACK (gs_plugin_flatpak_changed_cb), self);
/* ensure the legacy AppStream symlink cache is deleted */
if (!gs_flatpak_symlinks_cleanup (self->installation, cancellable, error))
@@ -959,6 +961,9 @@ gs_flatpak_add_updates (GsFlatpak *self, GsAppList *list,
continue;
}
gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
+ gs_app_set_update_details (app, NULL);
+ gs_app_set_update_version (app, NULL);
+ gs_app_set_update_urgency (app, AS_URGENCY_KIND_UNKNOWN);
gs_app_set_size_download (app, 0);
gs_app_list_add (list_tmp, app);
}
@@ -1767,6 +1772,19 @@ gs_plugin_refine_item_size (GsFlatpak *self,
return TRUE;
}
+static void
+gs_flatpak_refine_appstream_release (AsApp *item, GsApp *app)
+{
+ AsRelease *rel = as_app_get_release_default (item);
+ if (!gs_app_is_installed (app))
+ return;
+ if (rel == NULL)
+ return;
+ if (as_release_get_version (rel) == NULL)
+ return;
+ gs_app_set_version (app, as_release_get_version (rel));
+}
+
static gboolean
gs_flatpak_refine_appstream (GsFlatpak *self, GsApp *app, GError **error)
{
@@ -1787,7 +1805,13 @@ gs_flatpak_refine_appstream (GsFlatpak *self, GsApp *app, GError **error)
AS_STORE_SEARCH_FLAG_USE_WILDCARDS);
if (item == NULL)
return TRUE;
- return gs_appstream_refine_app (self->plugin, app, item, error);
+ if (!gs_appstream_refine_app (self->plugin, app, item, error))
+ return FALSE;
+
+ /* use the default release as the version number */
+ gs_flatpak_refine_appstream_release (item, app);
+
+ return TRUE;
}
gboolean
@@ -2196,6 +2220,11 @@ gs_flatpak_app_install (GsFlatpak *self,
/* state is known */
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+
+ /* set new version */
+ if (!gs_flatpak_refine_appstream (self, app, error))
+ return FALSE;
+
return TRUE;
}
@@ -2233,6 +2262,14 @@ gs_flatpak_update_app (GsFlatpak *self,
/* state is known */
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+ gs_app_set_update_version (app, NULL);
+ gs_app_set_update_details (app, NULL);
+ gs_app_set_update_urgency (app, AS_URGENCY_KIND_UNKNOWN);
+
+ /* set new version */
+ if (!gs_flatpak_refine_appstream (self, app, error))
+ return FALSE;
+
return TRUE;
}
@@ -2758,6 +2795,11 @@ gs_flatpak_finalize (GObject *object)
g_return_if_fail (GS_IS_FLATPAK (object));
self = GS_FLATPAK (object);
+ if (self->changed_id > 0) {
+ g_signal_handler_disconnect (self->monitor, self->changed_id);
+ self->changed_id = 0;
+ }
+
g_object_unref (self->plugin);
g_object_unref (self->store);
g_hash_table_unref (self->broken_remotes);
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 343ae45..d6ab82a 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -39,6 +39,7 @@
struct GsPluginData {
AsStore *store;
GHashTable *app_hash_old;
+ guint store_changed_id;
};
#define GS_PLUGIN_NUMBER_CHANGED_RELOAD 10
@@ -186,7 +187,10 @@ void
gs_plugin_destroy (GsPlugin *plugin)
{
GsPluginData *priv = gs_plugin_get_data (plugin);
- g_hash_table_unref (priv->app_hash_old);
+ if (priv->store_changed_id != 0)
+ g_signal_handler_disconnect (priv->store, priv->store_changed_id);
+ if (priv->app_hash_old != NULL)
+ g_hash_table_unref (priv->app_hash_old);
g_object_unref (priv->store);
}
@@ -292,9 +296,10 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
priv->app_hash_old = gs_plugin_appstream_create_app_hash (priv->store);
/* watch for changes */
- g_signal_connect (priv->store, "changed",
- G_CALLBACK (gs_plugin_appstream_store_changed_cb),
- plugin);
+ priv->store_changed_id =
+ g_signal_connect (priv->store, "changed",
+ G_CALLBACK (gs_plugin_appstream_store_changed_cb),
+ plugin);
/* ensure the token cache */
as_store_load_search_cache (priv->store);
diff --git a/src/plugins/gs-plugin-flatpak.c b/src/plugins/gs-plugin-flatpak.c
index c94e1e4..1c87277 100644
--- a/src/plugins/gs-plugin-flatpak.c
+++ b/src/plugins/gs-plugin-flatpak.c
@@ -128,6 +128,9 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
{
GsPluginData *priv = gs_plugin_get_data (plugin);
+ /* clear in case we're called from resetup in the self tests */
+ g_ptr_array_set_size (priv->flatpaks, 0);
+
/* we use a permissions helper to elevate privs */
if (priv->has_system_helper && priv->destdir_for_tests == NULL) {
g_autoptr(FlatpakInstallation) installation = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]