Improve detection of "unknown" travis builds

pull/831/head
Tom Parker-Shemilt 4 years ago
parent 584d8fca82
commit ecd6658ec6

@ -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…
Cancel
Save