Browse Source

properly handle the server's publish response

feat/mass-publish-tool
Jonathan Strong 1 year ago
parent
commit
7ae5ab55d5
  1. 31
      src/publish.rs

31
src/publish.rs

@ -498,6 +498,13 @@ async fn get_index_metas(
Ok(crate_versions) Ok(crate_versions)
} }
#[derive(Debug, Clone, Deserialize, Eq, PartialEq)]
pub struct PublishWarnings {
pub invalid_categories: Vec<String>,
pub invalid_badges: Vec<String>,
pub other: Vec<String>,
}
async fn process_crates( async fn process_crates(
config: &Config, config: &Config,
crate_versions: HashMap<String, Vec<IndexMeta>>, crate_versions: HashMap<String, Vec<IndexMeta>>,
@ -570,17 +577,35 @@ async fn process_crates(
debug!(status = ?resp.status(), "rcvd server response to publish request"); debug!(status = ?resp.status(), "rcvd server response to publish request");
let resp_body: serde_json::Value = resp let warnings: PublishWarnings = resp
.error_for_status()? .error_for_status()?
.json() .json()
.await?; .await?;
debug!("server response body:\n{resp_body:#?}"); let mut any_warnings = false;
for warning in warnings.invalid_categories.iter() {
warn!(%crate_name, %version, "registry server invalid category warning: {}", warning);
any_warnings = true;
}
for warning in warnings.invalid_badges.iter() {
warn!(%crate_name, %version, "registry server invalid badge warning: {}", warning);
any_warnings = true;
}
for warning in warnings.other.iter() {
warn!(%crate_name, %version, "registry server 'other' warning: {}", warning);
any_warnings = true;
}
trace!("server response body:\n{warnings:#?}");
info!( info!(
%crate_name, %crate_name,
%version, %version,
"published crate version", any_warnings,
"published crate version!",
); );
} }
} }

Loading…
Cancel
Save