summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <matthias.clasen@gmail.com>2019-12-04 11:48:47 -0500
committerGitHub <noreply@github.com>2019-12-04 11:48:47 -0500
commit44b6bc7f98b6618e0de2b17925412dff5aedb119 (patch)
tree009ffe0b921ed388f01e4690c2341b9d5ff5c2f9
parent849f448732558c624b24aa0a82b8eed8de1d00ef (diff)
parent4ab74d07c052389f280963b5031c0efa13ebdebb (diff)
downloadflatpak-44b6bc7f98b6618e0de2b17925412dff5aedb119.tar.gz
Merge pull request #3259 from uajain/uajain/cache-remote-state
installation: Cache remote states while querying installed refs
-rw-r--r--common/flatpak-installation.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/common/flatpak-installation.c b/common/flatpak-installation.c
index c2bfef4d..9928ef57 100644
--- a/common/flatpak-installation.c
+++ b/common/flatpak-installation.c
@@ -1030,6 +1030,7 @@ flatpak_installation_list_installed_refs_for_update (FlatpakInstallation *self,
g_autoptr(GPtrArray) installed = NULL; /* (element-type FlatpakInstalledRef) */
g_autoptr(GPtrArray) remotes = NULL; /* (element-type FlatpakRemote) */
g_autoptr(GHashTable) remote_commits = NULL; /* (element-type utf8 utf8) */
+ g_autoptr(GHashTable) remote_states = NULL; /* (element-type utf8 FlatpakRemoteState) */
int i, j;
g_autoptr(FlatpakDir) dir = NULL;
g_auto(OstreeRepoFinderResultv) results = NULL;
@@ -1093,9 +1094,11 @@ flatpak_installation_list_installed_refs_for_update (FlatpakInstallation *self,
if (dir == NULL)
return NULL;
+ remote_states = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) flatpak_remote_state_unref);
+
for (i = 0; i < installed->len; i++)
{
- g_autoptr(FlatpakRemoteState) state = NULL;
+ FlatpakRemoteState *state;
FlatpakInstalledRef *installed_ref = g_ptr_array_index (installed, i);
const char *remote_name = flatpak_installed_ref_get_origin (installed_ref);
g_autofree char *full_ref = flatpak_ref_format_ref (FLATPAK_REF (installed_ref));
@@ -1123,9 +1126,16 @@ flatpak_installation_list_installed_refs_for_update (FlatpakInstallation *self,
* This makes sure that the ref (maybe an app or runtime) remains in usable
* state and fixes itself through an update.
*/
- state = flatpak_dir_get_remote_state_optional (dir, remote_name, FALSE, cancellable, error);
+ state = g_hash_table_lookup (remote_states, remote_name);
if (state == NULL)
- continue;
+ {
+
+ state = flatpak_dir_get_remote_state_optional (dir, remote_name, FALSE, cancellable, error);
+ if (state == NULL)
+ continue;
+
+ g_hash_table_insert (remote_states, g_strdup (remote_name), state);
+ }
if (flatpak_dir_check_installed_ref_missing_related_ref (dir, state, full_ref, cancellable))
{