Skip to content

Commit

Permalink
add progress bar to publish upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Sep 24, 2024
1 parent aa5b54e commit 66639c1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/commands/publish.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::progress::ProgressStream;

use super::CommonOptions;
use anyhow::{anyhow, bail, Context, Result};
use clap::{Args, Subcommand};
Expand Down Expand Up @@ -197,14 +199,19 @@ impl PublishReleaseCommand {
let path = self.path.clone();
let version = self.version.clone();
match enqueue(&client, &self.name, move |c| async move {
let file = tokio::fs::File::open(&path)
.await
.with_context(|| format!("failed to open `{path}`", path = path.display()))?;
let file_len = file.metadata().await?.len();
let reader = BufReader::new(file);
let content = c
.content()
.store_content(
Box::pin(
ReaderStream::new(BufReader::new(
tokio::fs::File::open(&path).await.with_context(|| {
format!("failed to open `{path}`", path = path.display())
})?,
ReaderStream::new(ProgressStream::new(
reader,
file_len,
format!("uploading {path:?}.."),
))
.map_err(|e| anyhow!(e)),
),
Expand Down

0 comments on commit 66639c1

Please sign in to comment.