diff options
author | John Hiesey <john@hiesey.com> | 2019-10-24 09:10:57 -0600 |
---|---|---|
committer | Dan Nicholson <nicholson@endlessm.com> | 2020-01-20 20:42:27 -0700 |
commit | 291e9da258dc2c5b7cd5191f1c29e9b5f9d79b3b (patch) | |
tree | 2256d078bc5fd841aade856bf2ad29ae8739a5ba /src/libostree/ostree-repo-commit.c | |
parent | a4592678aa5b71051daed24d08bcc84d8844781c (diff) | |
download | ostree-291e9da258dc2c5b7cd5191f1c29e9b5f9d79b3b.tar.gz |
lib/commit: Include object type in sizes metadata
Append a byte encoding the OSTree object type for each object in the
metadata. This allows the commit metadata to be fetched and then for the
program to see which objects it already has for an accurate calculation
of which objects need to be downloaded.
This slightly breaks the `ostree.sizes` `ay` metadata entries. However,
it's unlikely anyone was asserting the length of the entries since the
array currently ends in 2 variable length integers. As far as I know,
the only users of the sizes metadata are the ostree test suite and
Endless' eos-updater[1]. The former is updated here and the latter
already expects this format.
1. https://github.com/endlessm/eos-updater/
Diffstat (limited to 'src/libostree/ostree-repo-commit.c')
-rw-r--r-- | src/libostree/ostree-repo-commit.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index f88e2d78..2294c846 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -322,16 +322,19 @@ commit_loose_regfile_object (OstreeRepo *self, /* This is used by OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES */ typedef struct { + OstreeObjectType objtype; goffset unpacked; goffset archived; } OstreeContentSizeCacheEntry; static OstreeContentSizeCacheEntry * -content_size_cache_entry_new (goffset unpacked, - goffset archived) +content_size_cache_entry_new (OstreeObjectType objtype, + goffset unpacked, + goffset archived) { OstreeContentSizeCacheEntry *entry = g_slice_new0 (OstreeContentSizeCacheEntry); + entry->objtype = objtype; entry->unpacked = unpacked; entry->archived = archived; @@ -399,7 +402,7 @@ repo_store_size_entry (OstreeRepo *self, repo_ensure_size_entries (self); g_hash_table_replace (self->object_sizes, g_strdup (checksum), - content_size_cache_entry_new (unpacked, archived)); + content_size_cache_entry_new (objtype, unpacked, archived)); } static int @@ -450,6 +453,7 @@ add_size_index_to_metadata (OstreeRepo *self, g_hash_table_lookup (self->object_sizes, e_checksum); _ostree_write_varuint64 (buffer, e_size->archived); _ostree_write_varuint64 (buffer, e_size->unpacked); + g_string_append_c (buffer, (gchar) e_size->objtype); g_variant_builder_add (&index_builder, "@ay", ot_gvariant_new_bytearray ((guint8*)buffer->str, buffer->len)); |