forked from Mirrors/flatpak-builder
build-update-repo: Reuse cache info from old summary
This makes rebuilding partial changes much faster.tingping/wmclass
parent
ba377b29e6
commit
e50f7a363f
|
@ -2068,7 +2068,7 @@ flatpak_repo_update (OstreeRepo *repo,
|
|||
GVariantBuilder ref_data_builder;
|
||||
GKeyFile *config;
|
||||
g_autofree char *title = NULL;
|
||||
|
||||
g_autoptr(GVariant) old_summary = NULL;
|
||||
g_autoptr(GHashTable) refs = NULL;
|
||||
const char *prefixes[] = { "appstream", "app", "runtime", NULL };
|
||||
const char **prefix;
|
||||
|
@ -2113,11 +2113,58 @@ flatpak_repo_update (OstreeRepo *repo,
|
|||
}
|
||||
}
|
||||
|
||||
ordered_keys = g_hash_table_get_keys (refs);
|
||||
ordered_keys = g_list_sort (ordered_keys, (GCompareFunc) strcmp);
|
||||
|
||||
commit_data_cache = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, commit_data_free);
|
||||
|
||||
old_summary = flatpak_repo_load_summary (repo, NULL);
|
||||
if (old_summary != NULL)
|
||||
{
|
||||
g_autoptr(GVariant) extensions = g_variant_get_child_value (old_summary, 1);
|
||||
g_autoptr(GVariant) cache_v = g_variant_lookup_value (extensions, "xa.cache", NULL);
|
||||
g_autoptr(GVariant) cache = NULL;
|
||||
if (cache_v != NULL)
|
||||
{
|
||||
cache = g_variant_get_child_value (cache_v, 0);
|
||||
gsize n, i;
|
||||
|
||||
n = g_variant_n_children (cache);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
g_autoptr(GVariant) old_element = g_variant_get_child_value (cache, i);
|
||||
g_autoptr(GVariant) old_ref_v = g_variant_get_child_value (old_element, 0);
|
||||
const char *old_ref = g_variant_get_string (old_ref_v, NULL);
|
||||
g_autofree char *old_rev = NULL;
|
||||
g_autoptr(GVariant) old_commit_data_v = g_variant_get_child_value (old_element, 1);
|
||||
CommitData *old_rev_data;
|
||||
|
||||
if (flatpak_summary_lookup_ref (old_summary, old_ref, &old_rev))
|
||||
{
|
||||
guint64 old_installed_size, old_download_size;
|
||||
g_autofree char *old_metadata = NULL;
|
||||
|
||||
/* See if we already have the info on this revision */
|
||||
if (g_hash_table_lookup (commit_data_cache, old_rev))
|
||||
continue;
|
||||
|
||||
g_variant_get_child (old_commit_data_v, 0, "t", &old_installed_size);
|
||||
old_installed_size = GUINT64_FROM_BE (old_installed_size);
|
||||
g_variant_get_child (old_commit_data_v, 1, "t", &old_download_size);
|
||||
old_download_size = GUINT64_FROM_BE (old_download_size);
|
||||
g_variant_get_child (old_commit_data_v, 2, "s", &old_metadata);
|
||||
|
||||
old_rev_data = g_new (CommitData, 1);
|
||||
old_rev_data->installed_size = old_installed_size;
|
||||
old_rev_data->download_size = old_download_size;
|
||||
old_rev_data->metadata_contents = g_steal_pointer (&old_metadata);
|
||||
|
||||
g_hash_table_insert (commit_data_cache, g_steal_pointer (&old_rev), old_rev_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ordered_keys = g_hash_table_get_keys (refs);
|
||||
ordered_keys = g_list_sort (ordered_keys, (GCompareFunc) strcmp);
|
||||
for (l = ordered_keys; l; l = l->next)
|
||||
{
|
||||
const char *ref = l->data;
|
||||
|
|
Loading…
Reference in New Issue