From 99b24bd7412556f09405112962a17731ef86fe81 Mon Sep 17 00:00:00 2001 From: Yihau Chen Date: Fri, 15 Sep 2023 02:44:12 +0800 Subject: [PATCH] check source_path before delete it (#33255) --- sdk/cargo-build-sbf/src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/cargo-build-sbf/src/main.rs b/sdk/cargo-build-sbf/src/main.rs index 6dd710e062..1a9e4e1b62 100644 --- a/sdk/cargo-build-sbf/src/main.rs +++ b/sdk/cargo-build-sbf/src/main.rs @@ -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