Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

test: check the existence of target_path_parent before detelting #33812

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions sdk/cargo-build-sbf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,14 +626,16 @@ fn build_solana_package(
// The package version directory doesn't contain a valid
// installation, and it should be removed.
let target_path_parent = target_path.parent().expect("Invalid package path");
fs::remove_dir_all(target_path_parent).unwrap_or_else(|err| {
error!(
"Failed to remove {} while recovering from installation failure: {}",
target_path_parent.to_string_lossy(),
err,
);
exit(1);
});
if target_path_parent.exists() {
fs::remove_dir_all(target_path_parent).unwrap_or_else(|err| {
error!(
"Failed to remove {} while recovering from installation failure: {}",
target_path_parent.to_string_lossy(),
err,
);
exit(1);
});
}
error!("Failed to install platform-tools: {}", err);
exit(1);
});
Expand Down