diff --git a/tools/codegen/src/main.rs b/tools/codegen/src/main.rs index e2b9a58c..9e426aa2 100644 --- a/tools/codegen/src/main.rs +++ b/tools/codegen/src/main.rs @@ -319,7 +319,7 @@ fn main() -> Result<()> { if download_cache.is_file() { eprintln!("already downloaded"); - fs::File::open(download_cache)?.read_to_end(&mut buf)?; + fs::File::open(download_cache)?.read_to_end(&mut buf)?; // Not buffered because it is read at once. } else { response.into_body().into_reader().read_to_end(&mut buf)?; eprintln!("download complete"); diff --git a/tools/codegen/src/tools-markdown.rs b/tools/codegen/src/tools-markdown.rs index fa6409b2..f2498340 100644 --- a/tools/codegen/src/tools-markdown.rs +++ b/tools/codegen/src/tools-markdown.rs @@ -1,6 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -use std::{env, fmt, io::Write as _, path::PathBuf}; +use std::{ + env, fmt, + io::{BufWriter, Write as _}, + path::PathBuf, +}; use anyhow::Result; use fs_err as fs; @@ -111,8 +115,7 @@ fn main() -> Result<()> { let mut markdown_file = workspace_root.clone(); markdown_file.push("TOOLS.md"); - let file = std::fs::File::create(markdown_file).expect("Unable to create file"); - let mut file = std::io::BufWriter::new(file); + let mut file = BufWriter::new(fs::File::create(markdown_file).unwrap()); // Buffered because it is written many times. file.write_all(HEADER.as_bytes()).expect("Unable to write header"); @@ -121,6 +124,7 @@ fn main() -> Result<()> { } file.write_all(FOOTER.as_bytes()).expect("Unable to write footer"); + file.flush()?; Ok(()) }