1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-29 16:30:56 -05:00

fix(registry): wait for already pending publish (#21663)

Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
Bartek Iwańczuk 2024-01-08 16:25:18 +01:00
parent e667497b6b
commit 5ef16d0a08
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
2 changed files with 21 additions and 3 deletions

View file

@ -53,6 +53,8 @@ pub struct PublishingTask {
pub struct ApiError { pub struct ApiError {
pub code: String, pub code: String,
pub message: String, pub message: String,
#[serde(flatten)]
pub data: serde_json::Value,
#[serde(skip)] #[serde(skip)]
pub x_deno_ray: Option<String>, pub x_deno_ray: Option<String>,
} }
@ -97,6 +99,7 @@ pub async fn parse_response<T: DeserializeOwned>(
code: "unknown".to_string(), code: "unknown".to_string(),
message: format!("{}: {}", status, text), message: format!("{}: {}", status, text),
x_deno_ray, x_deno_ray,
data: serde_json::json!({}),
}; };
return Err(err); return Err(err);
} }
@ -107,6 +110,7 @@ pub async fn parse_response<T: DeserializeOwned>(
code: "unknown".to_string(), code: "unknown".to_string(),
message: format!("Failed to parse response: {}, response: '{}'", err, text), message: format!("Failed to parse response: {}, response: '{}'", err, text),
x_deno_ray, x_deno_ray,
data: serde_json::json!({}),
}) })
} }

View file

@ -555,16 +555,30 @@ async fn publish_package(
let res = api::parse_response::<api::PublishingTask>(response).await; let res = api::parse_response::<api::PublishingTask>(response).await;
let mut task = match res { let mut task = match res {
Ok(task) => task, Ok(task) => task,
Err(err) if err.code == "duplicateVersionPublish" => { Err(mut err) if err.code == "duplicateVersionPublish" => {
let task = serde_json::from_value::<api::PublishingTask>(
err.data.get_mut("task").unwrap().take(),
)
.unwrap();
if task.status == "success" {
println!( println!(
"{} @{}/{}@{}", "{} @{}/{}@{}",
colors::yellow("Skipping, already published"), colors::green("Skipping, already published"),
package.scope, package.scope,
package.package, package.package,
package.version package.version
); );
return Ok(()); return Ok(());
} }
println!(
"{} @{}/{}@{}",
colors::yellow("Already uploaded, waiting for publishing"),
package.scope,
package.package,
package.version
);
task
}
Err(err) => { Err(err) => {
return Err(err).with_context(|| { return Err(err).with_context(|| {
format!( format!(