Add cargo-build-bpf logic to recover from failed package downloads (#21138)

This commit is contained in:
Dmitri Makarov 2021-11-02 15:41:06 -07:00 committed by GitHub
parent 9ff92cb0dc
commit b9eee66f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -132,6 +132,20 @@ fn install_if_missing(
.join(version)
.join(package);
// Check whether the target path is an empty directory. This can
// happen if package download failed on previous run of
// cargo-build-bpf. Remove the target_path directory in this
// case.
if target_path.is_dir()
&& target_path
.read_dir()
.map_err(|err| err.to_string())?
.next()
.is_none()
{
fs::remove_dir(&target_path).map_err(|err| err.to_string())?;
}
if !target_path.is_dir()
&& !target_path
.symlink_metadata()