aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamen Mladenov <kamen@syndamia.com>2025-04-29 16:34:19 +0300
committerKamen Mladenov <kamen@syndamia.com>2025-05-02 15:32:54 +0300
commitc427fed7a28aee28579806fdc7cb432fd8f6a0c0 (patch)
treee1a72380ad8299a6b29d2a07e05a22c2babbdace
parent1112cce22f81341dfd0553034ca927e823bb36bf (diff)
downloadzkVMs-benchmarks-c427fed7a28aee28579806fdc7cb432fd8f6a0c0.tar
zkVMs-benchmarks-c427fed7a28aee28579806fdc7cb432fd8f6a0c0.tar.gz
zkVMs-benchmarks-c427fed7a28aee28579806fdc7cb432fd8f6a0c0.zip
fix(zkvms_host_io): Truncate output file in emit_benchmark_results when appropriate
If we're not appending to a file with contents, then when we write our data, we're going to be overwriting the old data. If the old data is longer than the new one, we'll have some leftover text in the end, which will cause a problem with JSON parsing. We'll be truncating the file (i.e. emptying it out), but only when not appending to it.
-rw-r--r--zkvms_host_io/src/lib.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/zkvms_host_io/src/lib.rs b/zkvms_host_io/src/lib.rs
index ff69474..bf7ebc4 100644
--- a/zkvms_host_io/src/lib.rs
+++ b/zkvms_host_io/src/lib.rs
@@ -201,6 +201,7 @@ pub fn emit_benchmark_results(run_info: RunWith, starts: Vec<Instant>, ends: Vec
.write(true)
.create(true)
.append(run_info.append)
+ .truncate(!run_info.append)
.open(&path)
{
Ok(file) => file,