Elffuss BraidHub

utopia-ia/elffuss-braid public

verify: record file names stay under 143 bytes

Some encrypted file systems take file names of at most 143 bytes. A branch
name now gives its record a name in hex only up to 64 bytes, so that the
file name, with the .new of the scratch file it is written through, stays
under that; a longer one is hashed, as before.
Changeset52e22f93c9da7ca9d64a4ea4b61cbbc307c0fcf26a0573606cee1fe24ca59bee
AuthorKikoCis <KikoCis@users.noreply.github.com> · 2026-10-21 16:45 +02:00
CommitterKikoCis <KikoCis@users.noreply.github.com> · 2026-10-21 16:45 +02:00
Parents8e35586609e3

Browse the files at this changeset

1 file changed

modified crates/cli/src/verify.rs +11 −5
@@ -68,9 +68,11 @@
6868 /// the last hour, at most.
6969 const HISTORY_DEPTH: usize = 10_000;
7070
71-/// The longest record file name made of the branch's name in hex; a longer
72-/// name is hashed instead.
73-const MAX_HEX_NAME: usize = 200;
71+/// The longest branch name in hex that a record file is named with; a
72+/// longer name is hashed instead. With `.json`, and the `.new` of the
73+/// scratch file the record is written through, a file name stays under 143
74+/// bytes, the most some encrypted file systems take.
75+const MAX_HEX_NAME: usize = 128;
7476
7577 /// What the watchdog says once it runs, before braid starts any test. The
7678 /// number changes with the protocol, so that another braid's watchdog is
@@ -1407,8 +1409,12 @@
14071409 format!("b3-{}.json", blake3::hash(longer.as_bytes()).to_hex())
14081410 );
14091411 assert_ne!(name(&format!("{longest}y")), hashed);
1410- // Even the longest branch name a ref can have fits a file name.
1411- assert!(name(&"z".repeat(4096)).len() < 100);
1412+ // The longest file names, with the scratch file's `.new`, stay under
1413+ // 143 bytes, whatever the length of the branch's name.
1414+ for branch in [longest, longer, "z".repeat(4096)] {
1415+ let scratch = format!("{}.new", name(&branch));
1416+ assert!(scratch.len() < 143, "{scratch}");
1417+ }
14121418 }
14131419
14141420 #[test]