Skip to content

Commit

Permalink
remove the file and bail when write file error
Browse files Browse the repository at this point in the history
  • Loading branch information
Halimao committed Dec 3, 2023
1 parent 3887582 commit 873596c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ pub fn download_file(url: &str, path: &PathBuf) -> Result<()> {
response.into_reader().read_to_end(&mut data)?;

if let Err(e) = file.write_all(&data) {
error!(
fs::remove_file(path)?;
bail!(
"Something went wrong writing data to {}: {}",
path.display(),
e
Expand Down

0 comments on commit 873596c

Please sign in to comment.