Skip to content

Commit

Permalink
feat: skip manifest 404 not found if branch is topic
Browse files Browse the repository at this point in the history
  • Loading branch information
eatradish committed Jun 3, 2024
1 parent b621b45 commit 9334d37
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/network.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::{anyhow, Result};
use rayon::prelude::*;
use reqwest::blocking::Client;
use reqwest::StatusCode;
use std::{fs::File, io::Write};
use std::{
path::Path,
Expand Down Expand Up @@ -44,7 +45,11 @@ pub fn fetch_url(client: &Client, url: &str, path: &Path) -> Result<()> {
}

#[inline]
fn combination<'a, 'b, 'c>(a: &'a [&str], b: &'b [&str], c: &'c [&str]) -> Vec<(&'a str, &'b str, &'c str)> {
fn combination<'a, 'b, 'c>(
a: &'a [&str],
b: &'b [&str],
c: &'c [&str],
) -> Vec<(&'a str, &'b str, &'c str)> {
let mut ret = Vec::new();
for i in a {
for j in b {
Expand Down Expand Up @@ -78,6 +83,23 @@ pub fn fetch_manifests(
let parsed = Url::parse(&url)?;
let manifest_name = parsed.host_str().unwrap_or_default().to_string() + parsed.path();
let manifest_name = manifest_name.replace('/', "_");

if *branch != "stable" {
let resp = client.head(&url).send()?.error_for_status();

if let Err(e) = resp {
if e.status()
.map(|x| x == StatusCode::NOT_FOUND)
.unwrap_or(false)
{
eprintln!("{url} 404 NOT FOUND, skipping ...");
return Ok(());
} else {
return Err(e.into());
}
}
}

fetch_url(
client,
&url,
Expand Down

0 comments on commit 9334d37

Please sign in to comment.