diff --git a/uplink/src/collector/downloader.rs b/uplink/src/collector/downloader.rs index 893e94ec..ce5bbe38 100644 --- a/uplink/src/collector/downloader.rs +++ b/uplink/src/collector/downloader.rs @@ -93,6 +93,8 @@ pub enum Error { BadSave, #[error("Save file doesn't exist")] NoSave, + #[error("Download timedout")] + Timeout, } /// This struct contains the necessary components to download and store file as notified by a download file @@ -221,7 +223,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 Err(Error::Timeout); + }, } }