[gnome-software] snap: Reduce number of store hits
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] snap: Reduce number of store hits
- Date: Thu, 12 Dec 2019 14:23:58 +0000 (UTC)
commit 71243f2f6b3448bbf02b83567640a28778e46579
Author: Robert Ancell <robert ancell canonical com>
Date: Wed Dec 11 16:55:49 2019 +1300
snap: Reduce number of store hits
The snap plugin is currently hitting the store too many times, most noticibly
when browsing categories. This is due to it thinking it needed the channel
information even though the information on the current channel is already
available. This was introduced in b8b35b9 when supporting snap channels.
plugins/snap/gs-plugin-snap.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 2c90843d..88d2e2a0 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -821,7 +821,8 @@ gs_plugin_refine_app (GsPlugin *plugin,
{
GsPluginData *priv = gs_plugin_get_data (plugin);
g_autoptr(SnapdClient) client = NULL;
- const gchar *snap_name, *channel, *name, *version;
+ const gchar *snap_name, *channel, *store_channel = NULL, *name, *version;
+ gboolean need_details = FALSE;
SnapdConfinement confinement = SNAPD_CONFINEMENT_UNKNOWN;
g_autoptr(SnapdSnap) local_snap = NULL;
g_autoptr(SnapdSnap) store_snap = NULL;
@@ -840,10 +841,23 @@ gs_plugin_refine_app (GsPlugin *plugin,
snap_name = gs_app_get_metadata_item (app, "snap::name");
channel = gs_app_get_branch (app);
- /* get information from local snaps and store */
+ /* get information from locally installed snaps and information we already have */
local_snap = snapd_client_get_snap_sync (client, snap_name, cancellable, NULL);
- if (local_snap == NULL || (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS) != 0 || channel !=
NULL)
- store_snap = get_store_snap (plugin, snap_name, channel != NULL, cancellable, NULL);
+ store_snap = store_snap_cache_lookup (plugin, snap_name, FALSE);
+ if (store_snap != NULL)
+ store_channel = snapd_snap_get_channel (store_snap);
+
+ /* check if requested information requires us to go to the Snap Store */
+ if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS)
+ need_details = TRUE;
+ if (channel != NULL && g_strcmp0 (store_channel, channel) != 0)
+ need_details = TRUE;
+ if (need_details) {
+ g_clear_object (&store_snap);
+ store_snap = get_store_snap (plugin, snap_name, need_details, cancellable, NULL);
+ }
+
+ /* we don't know anything about this snap */
if (local_snap == NULL && store_snap == NULL)
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]