mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-08 05:40:31 +00:00
codegen: Tweak code around BufWriter
This commit is contained in:
@@ -319,7 +319,7 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
if download_cache.is_file() {
|
if download_cache.is_file() {
|
||||||
eprintln!("already downloaded");
|
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 {
|
} else {
|
||||||
response.into_body().into_reader().read_to_end(&mut buf)?;
|
response.into_body().into_reader().read_to_end(&mut buf)?;
|
||||||
eprintln!("download complete");
|
eprintln!("download complete");
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
// 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 anyhow::Result;
|
||||||
use fs_err as fs;
|
use fs_err as fs;
|
||||||
@@ -111,8 +115,7 @@ fn main() -> Result<()> {
|
|||||||
let mut markdown_file = workspace_root.clone();
|
let mut markdown_file = workspace_root.clone();
|
||||||
markdown_file.push("TOOLS.md");
|
markdown_file.push("TOOLS.md");
|
||||||
|
|
||||||
let file = std::fs::File::create(markdown_file).expect("Unable to create file");
|
let mut file = BufWriter::new(fs::File::create(markdown_file).unwrap()); // Buffered because it is written many times.
|
||||||
let mut file = std::io::BufWriter::new(file);
|
|
||||||
|
|
||||||
file.write_all(HEADER.as_bytes()).expect("Unable to write header");
|
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.write_all(FOOTER.as_bytes()).expect("Unable to write footer");
|
||||||
|
file.flush()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user