mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-08 18:05:42 +08:00
codegen: Tweak code around BufWriter
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user