Skip to content

Commit

Permalink
Merge pull request #4693 from wasmerio/upload-progressbar
Browse files Browse the repository at this point in the history
  • Loading branch information
xdoardo authored May 14, 2024
2 parents 81550fa + f44686f commit 9573519
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/cli/src/commands/package/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
};
use colored::Colorize;
use dialoguer::Confirm;
use indicatif::{ProgressBar, ProgressStyle};
use std::{
collections::BTreeMap,
path::{Path, PathBuf},
Expand Down Expand Up @@ -41,6 +42,7 @@ pub(super) async fn upload(
hash: &PackageHash,
timeout: humantime::Duration,
package: &Package,
pb: &ProgressBar,
) -> anyhow::Result<String> {
let hash_str = hash.to_string();
let hash_str = hash_str.trim_start_matches("sha256:");
Expand Down Expand Up @@ -114,6 +116,11 @@ pub(super) async fn upload(
let bytes = package.serialize()?;

let total_bytes = bytes.len();
pb.set_length(total_bytes.try_into().unwrap());
pb.set_style(ProgressStyle::with_template("{spinner:.green} [{elapsed_precise}] [{bar:.cyan/blue}] {bytes}/{total_bytes} ({bytes_per_sec}, {eta})")
.unwrap()
.progress_chars("█▉▊▋▌▍▎▏ ")
.tick_strings(&["✶", "✸", "✹", "✺", "✹", "✷"]));
tracing::info!("webc is {total_bytes} bytes long");

let chunk_size = 1_048_576; // 1MB - 315s / 100MB
Expand Down Expand Up @@ -144,6 +151,7 @@ pub(super) async fn upload(
})??;

total_bytes_sent += n;
pb.set_position(total_bytes_sent.try_into().unwrap());
}

Ok(url)
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/package/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl PackagePush {
) -> anyhow::Result<()> {
let pb = make_spinner!(self.quiet, "Uploading the package to the registry..");

let signed_url = upload(client, package_hash, self.timeout, package).await?;
let signed_url = upload(client, package_hash, self.timeout, package, &pb).await?;

let id = match wasmer_api::query::push_package_release(
client,
Expand Down

0 comments on commit 9573519

Please sign in to comment.