Skip to content

Commit 2c2417d

Browse files
authored
Merge pull request #2167 from kinnison/missing-download-dir-no-panic
utils: Silence NotFound in delete_dir_contents()
2 parents d9d7d7f + 1fd1056 commit 2c2417d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/utils/utils.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,15 @@ where
606606
}
607607

608608
pub fn delete_dir_contents(dir_path: &Path) {
609-
remove_dir_all::remove_dir_all(dir_path).expect("Failed to remove a dir");
609+
match remove_dir_all::remove_dir_all(dir_path) {
610+
Ok(_) => {}
611+
Err(e) => match e.kind() {
612+
io::ErrorKind::NotFound => {
613+
// Nothing to do here
614+
}
615+
_ => panic!("Unable to clean up {}: {:?}", dir_path.display(), e),
616+
},
617+
}
610618
}
611619

612620
pub struct FileReaderWithProgress<'a> {

0 commit comments

Comments
 (0)