Skip to content

Commit 29e3cfb

Browse files
committed
Improve asset upload output with status details
Show checksum match/changed/new status per asset instead of verbose HEAD debug output.
1 parent 809046d commit 29e3cfb

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "openworkers-cli"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
edition = "2024"
55
license = "MIT"
66
description = "CLI for OpenWorkers - Self-hosted Cloudflare Workers runtime"

src/commands/workers.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,18 +474,31 @@ async fn upload_assets_presigned(presigned: &[PresignedAsset], assets: &[Asset])
474474
{
475475
let hash_b64 = hex_to_base64(hash_hex);
476476

477-
// HEAD check: compare x-amz-checksum-sha256 with local hash
477+
// HEAD check: compare checksum and etag
478+
let mut checksum_match = false;
479+
let mut etag_match = false;
480+
478481
if let Ok(resp) = client.head(&asset_url.head_url).send().await {
479482
if resp.status().is_success() {
480483
if let Some(remote_hash) = resp.headers().get("x-amz-checksum-sha256") {
481-
if remote_hash.to_str().unwrap_or("") == hash_b64 {
482-
skipped += 1;
483-
continue;
484-
}
484+
checksum_match = remote_hash.to_str().unwrap_or("") == hash_b64;
485485
}
486+
487+
etag_match = resp.headers().get("etag").is_some();
486488
}
487489
}
488490

491+
if checksum_match {
492+
println!(
493+
" {} {} {}",
494+
"⎿".dimmed(),
495+
asset_url.path,
496+
format!("(skipped, checksum match)").dimmed()
497+
);
498+
skipped += 1;
499+
continue;
500+
}
501+
489502
// Upload
490503
match client
491504
.put(&asset_url.put_url)
@@ -497,7 +510,12 @@ async fn upload_assets_presigned(presigned: &[PresignedAsset], assets: &[Asset])
497510
.await
498511
{
499512
Ok(resp) if resp.status().is_success() => {
500-
println!(" {} {}", "⎿".dimmed(), asset_url.path);
513+
let reason = if etag_match {
514+
"checksum changed"
515+
} else {
516+
"new"
517+
};
518+
println!(" {} {} ({})", "⎿".dimmed(), asset_url.path, reason);
501519
uploaded += 1;
502520
}
503521
Ok(resp) => eprintln!(

0 commit comments

Comments
 (0)