From 2546446d51bd42bf13ce4d17926742545813dc51 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 5 Nov 2023 10:53:42 +0200 Subject: feat(tvix/castore): bump [Directory,File]Node size to u64 Having more than 4GiB files is quite possible (think about the NixOS graphical installer, and an uncompressed iso of it). No wire format changes. Change-Id: Ia78a07e4c554e91b93c5b9f8533266e4bd7f22b6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9950 Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/castore/src/proto/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tvix/castore/src/proto/mod.rs') diff --git a/tvix/castore/src/proto/mod.rs b/tvix/castore/src/proto/mod.rs index 07892ab799..c734e8be89 100644 --- a/tvix/castore/src/proto/mod.rs +++ b/tvix/castore/src/proto/mod.rs @@ -172,23 +172,23 @@ fn insert_once<'n>( Ok(()) } -fn checked_sum(iter: impl IntoIterator) -> Option { - iter.into_iter().try_fold(0u32, |acc, i| acc.checked_add(i)) +fn checked_sum(iter: impl IntoIterator) -> Option { + iter.into_iter().try_fold(0u64, |acc, i| acc.checked_add(i)) } impl Directory { /// The size of a directory is the number of all regular and symlink elements, /// the number of directory elements, and their size fields. - pub fn size(&self) -> u32 { + pub fn size(&self) -> u64 { if cfg!(debug_assertions) { self.size_checked() - .expect("Directory::size exceeds u32::MAX") + .expect("Directory::size exceeds u64::MAX") } else { - self.size_checked().unwrap_or(u32::MAX) + self.size_checked().unwrap_or(u64::MAX) } } - fn size_checked(&self) -> Option { + fn size_checked(&self) -> Option { checked_sum([ self.files.len().try_into().ok()?, self.symlinks.len().try_into().ok()?, -- cgit 1.4.1