[gnome-software] Remove the GsApp cache component if the backing AppStream AsApp is deleted
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Remove the GsApp cache component if the backing AppStream AsApp is deleted
- Date: Mon, 31 Oct 2016 16:51:02 +0000 (UTC)
commit 34e9dce2ac89106914323a590a06bc7b77b7fc7f
Author: Richard Hughes <richard hughsie com>
Date: Mon Oct 31 15:01:32 2016 +0000
Remove the GsApp cache component if the backing AppStream AsApp is deleted
This means we can update the AppStream file in-place and have the changes
reflected in the GNOME Software UI.
src/plugins/gs-flatpak.c | 10 ++++++++++
src/plugins/gs-plugin-appstream.c | 12 ++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 94fafc3..c044dc1 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -2666,6 +2666,13 @@ gs_flatpak_add_featured (GsFlatpak *self,
}
static void
+gs_flatpak_store_app_removed_cb (AsStore *store, AsApp *app, GsFlatpak *self)
+{
+ g_debug ("AppStream app was removed, doing delete from global cache");
+ gs_plugin_cache_remove (self->plugin, as_app_get_unique_id (app));
+}
+
+static void
gs_flatpak_finalize (GObject *object)
{
GsFlatpak *self;
@@ -2692,6 +2699,9 @@ gs_flatpak_init (GsFlatpak *self)
self->broken_remotes = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
self->store = as_store_new ();
+ g_signal_connect (self->store, "app-removed",
+ G_CALLBACK (gs_flatpak_store_app_removed_cb),
+ self);
as_store_set_add_flags (self->store, AS_STORE_ADD_FLAG_USE_UNIQUE_ID);
as_store_set_watch_flags (self->store, AS_STORE_WATCH_FLAG_REMOVED);
}
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index d365d37..0b861a3 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -132,6 +132,15 @@ gs_plugin_appstream_store_changed_cb (AsStore *store, GsPlugin *plugin)
gs_plugin_reload (plugin);
}
+static void
+gs_plugin_appstream_store_app_removed_cb (AsStore *store,
+ AsApp *app,
+ GsPlugin *plugin)
+{
+ g_debug ("AppStream app was removed, doing delete from global cache");
+ gs_plugin_cache_remove (plugin, as_app_get_unique_id (app));
+}
+
void
gs_plugin_initialize (GsPlugin *plugin)
{
@@ -266,6 +275,9 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
g_signal_connect (priv->store, "changed",
G_CALLBACK (gs_plugin_appstream_store_changed_cb),
plugin);
+ g_signal_connect (priv->store, "app-removed",
+ G_CALLBACK (gs_plugin_appstream_store_app_removed_cb),
+ plugin);
/* add search terms for apps not in the main source */
origins = gs_plugin_appstream_get_origins_hash (items);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]