Skip to content

Commit

Permalink
Add percent to output
Browse files Browse the repository at this point in the history
  • Loading branch information
arpad-m committed Jun 6, 2024
1 parent 4ad2aad commit b139e2e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pageserver/ctl/src/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ pub(crate) async fn main(cmd: &LayerCmd) -> Result<()> {
let semaphore = Arc::new(Semaphore::new(parallelism.unwrap_or(1) as usize));

let mut tasks = JoinSet::new();
for file_key in files_list.keys.iter() {
for (file_idx, file_key) in files_list.keys.iter().enumerate() {
let Some(file_name) = file_key.object_name() else {
continue;
};
Expand Down Expand Up @@ -360,6 +360,7 @@ pub(crate) async fn main(cmd: &LayerCmd) -> Result<()> {
let storage = storage.clone();
let tmp_dir = tmp_dir.to_owned();
let file_name = file_name.to_owned();
let percent = files_list.keys.len() * 100 / file_idx;
tasks.spawn(async move {
let stats = stats(
semaphore,
Expand All @@ -371,7 +372,9 @@ pub(crate) async fn main(cmd: &LayerCmd) -> Result<()> {
)
.await;
match stats {
Ok(stats) => println!("Statistics for {file_name}: {stats:?}\n"),
Ok(stats) => {
println!("Statistics for {file_name} ({percent}%): {stats:?}\n")
}
Err(e) => eprintln!("Error for {file_name}: {e:?}"),
};
});
Expand Down

0 comments on commit b139e2e

Please sign in to comment.