From 8cf4e010e93800368361c9e0c55ba8921aeb4d3d Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 5 Oct 2026 12:48:52 +0200 Subject: [PATCH] Truncate export files before rewriting results --- src/export/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/export/mod.rs b/src/export/mod.rs index 3eb4433..c8d51d7 100644 --- a/src/export/mod.rs +++ b/src/export/mod.rs @@ -158,7 +158,11 @@ impl ExportManager { /// Write the given content to a file with the specified name fn write_to_file(filename: &str, content: &[u8]) -> Result<()> { - let mut file = OpenOptions::new().write(true).open(filename)?; + let mut file = OpenOptions::new() + .write(true) + // Avoid leaving trailing bytes when the new export is shorter. + .truncate(true) + .open(filename)?; file.write_all(content) .with_context(|| format!("Failed to export results to '{filename}'")) }