check source_path before delete it (#33255)

This commit is contained in:
Yihau Chen 2023-09-15 02:44:12 +08:00 committed by GitHub
parent 596e17f74b
commit 99b24bd741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -247,8 +247,10 @@ fn install_if_missing(
let source_base = config.sbf_sdk.join("dependencies");
if source_base.exists() {
let source_path = source_base.join(package);
debug!("Remove file {:?}", source_path);
fs::remove_file(source_path).map_err(|err| err.to_string())?;
if source_path.exists() {
debug!("Remove file {:?}", source_path);
fs::remove_file(source_path).map_err(|err| err.to_string())?;
}
}
}
// Check whether the target path is an empty directory. This can