give a better error if renaming a temp file fails

This commit is contained in:
jyn 2023-11-11 11:01:36 -05:00
parent 0ffac661fa
commit 336ed0ebc7

View File

@ -208,7 +208,10 @@ impl Config {
Some(other) => panic!("unsupported protocol {other} in {url}"), Some(other) => panic!("unsupported protocol {other} in {url}"),
None => panic!("no protocol in {url}"), None => panic!("no protocol in {url}"),
} }
t!(std::fs::rename(&tempfile, dest_path)); t!(
std::fs::rename(&tempfile, dest_path),
format!("failed to rename {tempfile:?} to {dest_path:?}")
);
} }
fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) { fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) {
@ -544,6 +547,10 @@ impl Config {
key: &str, key: &str,
destination: &str, destination: &str,
) { ) {
if self.dry_run() {
return;
}
let cache_dst = self.out.join("cache"); let cache_dst = self.out.join("cache");
let cache_dir = cache_dst.join(key); let cache_dir = cache_dst.join(key);
if !cache_dir.exists() { if !cache_dir.exists() {