[gnome-software/gnome-41: 1/2] snap: Use channel name in plugin cache key.
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-41: 1/2] snap: Use channel name in plugin cache key.
- Date: Thu, 25 Nov 2021 08:26:39 +0000 (UTC)
commit ff7ca90c9baa58844a47afa27dd27b8dc053cc72
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Nov 25 16:31:17 2021 +1300
snap: Use channel name in plugin cache key.
The existing key didn't have the channel name, which stopped the alternates system from working.
This was broken in d0747ba25e0381b4f0ceb0cd67e1bd4adb94f774
plugins/snap/gs-plugin-snap.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 3a5a4d083..ebef3f4bd 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -326,22 +326,24 @@ snap_guess_component_kind (SnapdSnap *snap)
}
static GsApp *
-snap_to_app (GsPlugin *plugin, SnapdSnap *snap)
+snap_to_app (GsPlugin *plugin, SnapdSnap *snap, const gchar *branch)
{
- g_autofree gchar *appstream_id = NULL;
- g_autofree gchar *unique_id = NULL;
+ g_autofree gchar *cache_id = NULL;
g_autoptr(GsApp) app = NULL;
- appstream_id = get_appstream_id (snap);
- unique_id = g_strdup_printf ("system/snap/*/%s/*", appstream_id);
+ cache_id = g_strdup_printf ("%s:%s", snapd_snap_get_name (snap), branch != NULL ? branch : "");
- app = gs_plugin_cache_lookup (plugin, unique_id);
+ app = gs_plugin_cache_lookup (plugin, cache_id);
if (app == NULL) {
+ g_autofree gchar *appstream_id = NULL;
+
+ appstream_id = get_appstream_id (snap);
app = gs_app_new (appstream_id);
- gs_app_set_from_unique_id (app, unique_id, snap_guess_component_kind (snap));
+ gs_app_set_kind (app, snap_guess_component_kind (snap));
gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_SNAP);
+ gs_app_set_branch (app, branch);
gs_app_set_metadata (app, "snap::name", snapd_snap_get_name (snap));
- gs_plugin_cache_add (plugin, unique_id, app);
+ gs_plugin_cache_add (plugin, cache_id, app);
}
gs_app_set_management_plugin (app, "snap");
@@ -383,7 +385,7 @@ gs_plugin_url_to_app (GsPlugin *plugin,
if (snaps == NULL || snaps->len < 1)
return TRUE;
- app = snap_to_app (plugin, g_ptr_array_index (snaps, 0));
+ app = snap_to_app (plugin, g_ptr_array_index (snaps, 0), NULL);
gs_app_list_add (list, app);
return TRUE;
@@ -435,7 +437,7 @@ gs_plugin_add_popular (GsPlugin *plugin,
return FALSE;
for (i = 0; i < snaps->len; i++) {
- g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, i));
+ g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, i), NULL);
gs_app_list_add (list, app);
}
@@ -497,7 +499,7 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
if (snaps == NULL)
return FALSE;
for (j = 0; j < snaps->len; j++) {
- g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, j));
+ g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, j),
NULL);
gs_app_list_add (list, app);
}
}
@@ -529,7 +531,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
SnapdSnap *snap = g_ptr_array_index (snaps, i);
g_autoptr(GsApp) app = NULL;
- app = snap_to_app (plugin, snap);
+ app = snap_to_app (plugin, snap, NULL);
gs_app_list_add (list, app);
}
@@ -553,7 +555,7 @@ gs_plugin_add_search (GsPlugin *plugin,
return FALSE;
for (i = 0; i < snaps->len; i++) {
- g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, i));
+ g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, i), NULL);
gs_app_list_add (list, app);
}
@@ -666,9 +668,8 @@ add_channels (GsPlugin *plugin, SnapdSnap *snap, GsAppList *list)
g_autoptr(GsApp) app = NULL;
g_autofree gchar *expanded_name = NULL;
- app = snap_to_app (plugin, snap);
expanded_name = expand_channel_name (snapd_channel_get_name (channel));
- gs_app_set_branch (app, expanded_name);
+ app = snap_to_app (plugin, snap, expanded_name);
gs_app_list_add (list, app);
}
@@ -1402,7 +1403,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
g_autoptr(GsApp) app = NULL;
/* Convert SnapdSnap to a GsApp */
- app = snap_to_app (plugin, snap);
+ app = snap_to_app (plugin, snap, NULL);
/* If for some reason the app is already getting updated, then
* don't change its state */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]