Skip to content

Commit

Permalink
fix: delete partially downloaded file when handling a timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Devdutt Shenoi committed Apr 16, 2024
1 parent 500a578 commit 8507624
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion uplink/src/collector/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,13 @@ impl FileDownloader {
// NOTE: if download has timedout don't do anything, else ensure errors are forwarded after three retries
o = timeout_at(deadline, self.continuous_retry(state)) => match o {
Ok(r) => r?,
Err(_) => error!("Last download has timedout"),
Err(_) => {
// unwrap is safe because download_path is expected to be Some
_ = remove_file(state.current.meta.download_path.as_ref().unwrap());
error!("Last download has timedout; file deleted");

return Ok(());
},
}
}

Expand Down

0 comments on commit 8507624

Please sign in to comment.