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/
This commit is contained in:
1 parent
a4592678aa
commit
291e9da258
2 files changed
+48
-26
No files matched your search
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user