Download snapshot files with a tmp- prefix so they'll automatically be cleaned up if interrupted

(cherry picked from commit 58b980f9cd)
This commit is contained in:
Michael Vines
2021-03-16 23:04:05 -07:00
parent aa9772f9c0
commit 32124b59e9

View File

@ -34,9 +34,18 @@ pub fn download_file(
}
let download_start = Instant::now();
fs::create_dir_all(destination_file.parent().unwrap()).map_err(|err| err.to_string())?;
fs::create_dir_all(destination_file.parent().expect("parent"))
.map_err(|err| err.to_string())?;
let temp_destination_file = destination_file.with_extension("tmp");
let mut temp_destination_file = destination_file.to_path_buf();
temp_destination_file.set_file_name(format!(
"tmp-{}",
destination_file
.file_name()
.expect("file_name")
.to_str()
.expect("to_str")
));
let progress_bar = new_spinner_progress_bar();
if use_progress_bar {