Skip to content

Commit fc5a128

Browse files
committed
rust: don't attempt to upload asset that already exists
This is a better solution.
1 parent ba31ca6 commit fc5a128

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/github.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ pub async fn command_upload_release_distributions(args: &ArgMatches<'_>) -> Resu
245245
};
246246

247247
for filename in wanted_filenames.intersection(&filenames) {
248+
if release.assets.iter().any(|asset| &asset.name == filename) {
249+
println!("release asset {} already present; skipping", filename);
250+
continue;
251+
}
252+
248253
let path = dist_dir.join(filename);
249254
let file_data = std::fs::read(&path)?;
250255

@@ -269,11 +274,6 @@ pub async fn command_upload_release_distributions(args: &ArgMatches<'_>) -> Resu
269274

270275
let response = client.execute(request).await?;
271276

272-
if response.status() == 422 {
273-
println!("HTTP 422 when uploading {}; ignoring", filename);
274-
continue;
275-
}
276-
277277
if !response.status().is_success() {
278278
return Err(anyhow!("HTTP {}", response.status()));
279279
}

0 commit comments

Comments
 (0)