diff --git a/ort-sys/build.rs b/ort-sys/build.rs index 39aa6d7..5969a6f 100644 --- a/ort-sys/build.rs +++ b/ort-sys/build.rs @@ -453,13 +453,14 @@ fn prepare_libort_dir() -> (PathBuf, bool) { } extract_tgz(&downloaded_file, &temp_extract_dir); if should_rename { - match std::fs::rename(&temp_extract_dir, bin_extract_dir) { + match std::fs::rename(&temp_extract_dir, &bin_extract_dir) { Ok(()) => {} - Err(e) => match e.kind() { - io::ErrorKind::AlreadyExists => { + Err(e) => { + if bin_extract_dir.exists() { let _ = fs::remove_dir_all(temp_extract_dir); + } else { + panic!("failed to extract downloaded binaries: {e}"); } - _ => panic!("failed to extract downloaded binaries: {e}") } } }