Use u64 for item counts in binary export

They're still clamped to a u32 upon reading, but at least the file will
have correct counts and can be read even when it exceeds 4.2 billion
items.
This commit is contained in:
Yorhel 2024-08-08 11:37:53 +02:00
parent 49ef7cc34e
commit 252f7fc253
2 changed files with 3 additions and 3 deletions

View file

@ -39,7 +39,7 @@ pub const ItemKey = enum(u5) {
cumdsize = 8, // u64
shrasize = 9, // u64
shrdsize = 10, // u64
items = 11, // u32
items = 11, // u64
sub = 12, // itemref only if dir is not empty
// Only for .link
ino = 13, // u64
@ -217,7 +217,7 @@ pub const Dir = struct {
lock: std.Thread.Mutex = .{},
last_sub: u64 = 0,
stat: sink.Stat,
items: u32 = 0,
items: u64 = 0,
size: u64 = 0,
blocks: u64 = 0,
err: bool = false,

View file

@ -467,7 +467,7 @@ pub fn get(ref: u64, alloc: std.mem.Allocator) *model.Entry {
.cumdsize => entry.pack.blocks = @intCast(kv.val.int(u64)/512),
.shrasize => { if (entry.dir()) |d| d.shared_size = kv.val.int(u64); },
.shrdsize => { if (entry.dir()) |d| d.shared_blocks = kv.val.int(u64)/512; },
.items => { if (entry.dir()) |d| d.items = kv.val.int(u32); },
.items => { if (entry.dir()) |d| d.items = util.castClamp(u32, kv.val.int(u64)); },
.sub => { if (entry.dir()) |d| d.sub = .{ .ref = kv.val.itemref(ref) }; },
.ino => { if (entry.link()) |l| l.ino = kv.val.int(u64); },