From beb9635e1362cb07eed52b52f246902ee27c04f1 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Tue, 19 Nov 2024 09:46:52 +1300 Subject: [PATCH] A double check when counting/hashing --- src/filestore/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/filestore/mod.rs b/src/filestore/mod.rs index e7c991b..7d85a48 100644 --- a/src/filestore/mod.rs +++ b/src/filestore/mod.rs @@ -77,7 +77,12 @@ impl FileStore { }); // Copy the data into the tempfile (hashing and counting as we go) - tokio::io::copy(&mut inspect_reader, &mut tempfile).await?; + let count = tokio::io::copy(&mut inspect_reader, &mut tempfile).await?; + + // Verify our code was correct + if count != size { + return Err(ChorusError::General("INTERNAL COUNT MISMATCH".to_string()).into()); + } // Finish the hash let hash = HashOutput::from_engine(hash_engine);