mirror of
https://github.com/rust-unofficial/awesome-rust.git
synced 2025-03-17 20:17:57 +02:00
Improve detection of "unknown" travis builds
This commit is contained in:
parent
584d8fca82
commit
ecd6658ec6
13
src/main.rs
13
src/main.rs
@ -81,7 +81,7 @@ lazy_static! {
|
||||
static ref HANDLES: MaxHandles = MaxHandles::new(20);
|
||||
}
|
||||
|
||||
fn get_url(url: String) -> BoxFuture<'static, (String, Result<String, CheckerError>)> {
|
||||
fn get_url(url: String) -> BoxFuture<'static, (String, Result<(), CheckerError>)> {
|
||||
async move {
|
||||
let _handle = HANDLES.get().await;
|
||||
let mut res = Err(CheckerError::NotTried);
|
||||
@ -98,7 +98,7 @@ fn get_url(url: String) -> BoxFuture<'static, (String, Result<String, CheckerErr
|
||||
res = Err(CheckerError::ReqwestError{error: err});
|
||||
continue;
|
||||
}
|
||||
Ok(ref ok) => {
|
||||
Ok(ok) => {
|
||||
let status = ok.status();
|
||||
if status != StatusCode::OK {
|
||||
lazy_static! {
|
||||
@ -143,15 +143,16 @@ fn get_url(url: String) -> BoxFuture<'static, (String, Result<String, CheckerErr
|
||||
static ref TRAVIS_IMG_REGEX: Regex = Regex::new(r"https://api.travis-ci.(?:com|org)/[^/]+/.+\.svg").unwrap();
|
||||
}
|
||||
if TRAVIS_IMG_REGEX.is_match(&url) {
|
||||
let content_dispostion = ok.headers().get(header::CONTENT_DISPOSITION).and_then(|h| h.to_str().ok()).unwrap_or("");
|
||||
debug!("Content dispostion for {} is '{}'", content_dispostion, url);
|
||||
if content_dispostion == "inline; filename=\"unknown.svg\"" {
|
||||
// Previously we checked the Content-Disposition headers, but sometimes that is incorrect
|
||||
// We're now looking for the explicit text "unknown" in the middle of the SVG
|
||||
let content = ok.text().await.unwrap();
|
||||
if content.contains("unknown") {
|
||||
res = Err(CheckerError::TravisBuildUnknown);
|
||||
break;
|
||||
}
|
||||
}
|
||||
debug!("Finished {}", url);
|
||||
res = Ok(format!("{:?}", ok));
|
||||
res = Ok(());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user