Add cargo-build-bpf logic to recover from failed package downloads (#21138)
This commit is contained in:
@ -132,6 +132,20 @@ fn install_if_missing(
|
|||||||
.join(version)
|
.join(version)
|
||||||
.join(package);
|
.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()
|
if !target_path.is_dir()
|
||||||
&& !target_path
|
&& !target_path
|
||||||
.symlink_metadata()
|
.symlink_metadata()
|
||||||
|
Reference in New Issue
Block a user