Skip to content

Commit

Permalink
Merge pull request #10 from VoysAI/fix-build-rs-download-error
Browse files Browse the repository at this point in the history
Fix build.rs `download_file` error case
  • Loading branch information
ebraraktas authored Aug 18, 2022
2 parents e4ef81b + f76b2c0 commit a633d41
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,10 @@ fn download_file(url: &str, path: &Path) {
easy.url(url).unwrap();
easy.write_function(move |data| Ok(writer.write(data).unwrap()))
.unwrap();
easy.perform().unwrap();
easy.perform().unwrap_or_else(|e| {
std::fs::remove_file(path).unwrap(); // Delete corrupted or empty file
panic!("Error occurred while downloading from {}: {:?}", url, e);
});
}

fn main() {
Expand Down

0 comments on commit a633d41

Please sign in to comment.