Skip to content

Commit 0f1284c

Browse files
committed
Fix ./y.sh prepare when the download dir is clobbered
1 parent 0a9ce96 commit 0f1284c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

build_system/prepare.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::ffi::OsStr;
2-
use std::fs;
32
use std::hash::{Hash, Hasher};
43
use std::path::{Path, PathBuf};
54
use std::process::Command;
5+
use std::{fs, io};
66

77
use crate::path::{Dirs, RelPath};
88
use crate::utils::{copy_dir_recursively, ensure_empty_dir, spawn_and_wait};
@@ -155,6 +155,13 @@ impl GitRepo {
155155

156156
fn clone_repo(download_dir: &Path, repo: &str, rev: &str) {
157157
eprintln!("[CLONE] {}", repo);
158+
159+
match fs::remove_dir_all(download_dir) {
160+
Ok(()) => {}
161+
Err(err) if err.kind() == io::ErrorKind::NotFound => {}
162+
Err(err) => panic!("Failed to remove {path}: {err}", path = download_dir.display()),
163+
}
164+
158165
// Ignore exit code as the repo may already have been checked out
159166
git_command(None, "clone").arg(repo).arg(download_dir).spawn().unwrap().wait().unwrap();
160167

0 commit comments

Comments
 (0)