File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ fn main() -> Result<()> {
319319
320320 if download_cache. is_file ( ) {
321321 eprintln ! ( "already downloaded" ) ;
322- fs:: File :: open ( download_cache) ?. read_to_end ( & mut buf) ?;
322+ fs:: File :: open ( download_cache) ?. read_to_end ( & mut buf) ?; // Not buffered because it is read at once.
323323 } else {
324324 response. into_body ( ) . into_reader ( ) . read_to_end ( & mut buf) ?;
325325 eprintln ! ( "download complete" ) ;
Original file line number Diff line number Diff line change 11// SPDX-License-Identifier: Apache-2.0 OR MIT
22
3- use std:: { env, fmt, io:: Write as _, path:: PathBuf } ;
3+ use std:: {
4+ env, fmt,
5+ io:: { BufWriter , Write as _} ,
6+ path:: PathBuf ,
7+ } ;
48
59use anyhow:: Result ;
610use fs_err as fs;
@@ -111,8 +115,7 @@ fn main() -> Result<()> {
111115 let mut markdown_file = workspace_root. clone ( ) ;
112116 markdown_file. push ( "TOOLS.md" ) ;
113117
114- let file = std:: fs:: File :: create ( markdown_file) . expect ( "Unable to create file" ) ;
115- let mut file = std:: io:: BufWriter :: new ( file) ;
118+ let mut file = BufWriter :: new ( fs:: File :: create ( markdown_file) . unwrap ( ) ) ; // Buffered because it is written many times.
116119
117120 file. write_all ( HEADER . as_bytes ( ) ) . expect ( "Unable to write header" ) ;
118121
@@ -121,6 +124,7 @@ fn main() -> Result<()> {
121124 }
122125
123126 file. write_all ( FOOTER . as_bytes ( ) ) . expect ( "Unable to write footer" ) ;
127+ file. flush ( ) ?;
124128
125129 Ok ( ( ) )
126130}
You can’t perform that action at this time.
0 commit comments