Skip to content

Commit dab7051

Browse files
committed
rust: follow redirects when downloading artifacts
The recent commit to upgrade octocrab somehow regressed the following of redirects. Let's implement the following manually.
1 parent 584d07b commit dab7051

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/github.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ async fn fetch_artifact(client: &Octocrab, artifact: WorkflowListArtifact) -> Re
2626
println!("downloading {}", artifact.name);
2727
let res = client._get(artifact.archive_download_url.as_str()).await?;
2828

29+
let res = if res.status().is_redirection() {
30+
let location = res
31+
.headers()
32+
.get("Location")
33+
.ok_or_else(|| anyhow!("no Location header to follow redirect"))?;
34+
35+
client._get(location.to_str()?).await?
36+
} else {
37+
res
38+
};
39+
2940
Ok(hyper::body::to_bytes(res.into_body()).await?)
3041
}
3142

0 commit comments

Comments
 (0)