[gnome-software/wip/backport_merge_request_1409] flatpak: Use cached runtime only if it had been refined
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/backport_merge_request_1409] flatpak: Use cached runtime only if it had been refined
- Date: Wed, 22 Jun 2022 14:06:41 +0000 (UTC)
commit b57bceccfdf88cd96035d139afbdf40c0687af44
Author: Milan Crha <mcrha redhat com>
Date: Mon Jun 20 21:08:07 2022 +0200
flatpak: Use cached runtime only if it had been refined
The runtime can be added to the plugin cache through the appstream data,
but it doesn't mean it is also refined when it is asked for it, thus make
sure only runtime with necessary (and the same as expected) properties
is returned from the cache within gs_flatpak_create_runtime()
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1699
plugins/flatpak/gs-flatpak.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 2e791dc79..ca338867a 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -2369,21 +2369,32 @@ gs_flatpak_create_runtime (GsFlatpak *self,
/* search in the cache */
app_cache = gs_plugin_cache_lookup (self->plugin, gs_app_get_unique_id (app));
- if (app_cache != NULL) {
+ if (app_cache != NULL &&
+ g_strcmp0 (gs_flatpak_app_get_ref_name (app_cache), split[0]) == 0 &&
+ g_strcmp0 (gs_flatpak_app_get_ref_arch (app_cache), split[1]) == 0 &&
+ g_strcmp0 (gs_app_get_branch (app_cache), split[2]) == 0) {
/* since the cached runtime can have been created somewhere else
* (we're using a global cache), we need to make sure that a
* source is set */
if (gs_app_get_source_default (app_cache) == NULL)
gs_app_add_source (app_cache, source);
return g_steal_pointer (&app_cache);
+ } else {
+ g_clear_object (&app_cache);
}
/* if the app is per-user we can also use the installed system runtime */
if (gs_app_get_scope (parent) == AS_COMPONENT_SCOPE_USER) {
gs_app_set_scope (app, AS_COMPONENT_SCOPE_UNKNOWN);
app_cache = gs_plugin_cache_lookup (self->plugin, gs_app_get_unique_id (app));
- if (app_cache != NULL)
+ if (app_cache != NULL &&
+ g_strcmp0 (gs_flatpak_app_get_ref_name (app_cache), split[0]) == 0 &&
+ g_strcmp0 (gs_flatpak_app_get_ref_arch (app_cache), split[1]) == 0 &&
+ g_strcmp0 (gs_app_get_branch (app_cache), split[2]) == 0) {
return g_steal_pointer (&app_cache);
+ } else {
+ g_clear_object (&app_cache);
+ }
}
/* set superclassed app properties */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]