From c427fed7a28aee28579806fdc7cb432fd8f6a0c0 Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Tue, 29 Apr 2025 16:34:19 +0300 Subject: 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. --- zkvms_host_io/src/lib.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'zkvms_host_io') 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, ends: Vec .write(true) .create(true) .append(run_info.append) + .truncate(!run_info.append) .open(&path) { Ok(file) => file, -- cgit v1.2.3