diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/yt/src/update/updater.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/yt/src/update/updater.rs b/crates/yt/src/update/updater.rs index 934b84b..21e30ed 100644 --- a/crates/yt/src/update/updater.rs +++ b/crates/yt/src/update/updater.rs @@ -35,6 +35,8 @@ pub(super) struct Updater { pool: LocalPoolHandle, } +static REACHED_NUMBER: AtomicUsize = const { AtomicUsize::new(1) }; + impl Updater { pub(super) fn new(max_backlog: usize, hashes: Vec<Hash>) -> Self { // TODO(@bpeetz): The number should not be hardcoded. <2025-06-14> @@ -48,8 +50,10 @@ impl Updater { } pub(super) async fn update(self, app: &App, subscriptions: Vec<Subscription>) -> Result<()> { + let total_number = subscriptions.len(); + let mut stream = stream::iter(subscriptions) - .map(|sub| self.get_new_entries(sub)) + .map(|sub| self.get_new_entries(sub, total_number)) .buffer_unordered(16 * 4); while let Some(output) = stream.next().await { @@ -72,6 +76,7 @@ impl Updater { async fn get_new_entries( &self, sub: Subscription, + total_number: usize, ) -> Result<impl Iterator<Item = (Subscription, InfoJson)>> { let max_backlog = self.max_backlog; let hashes = self.hashes.clone(); @@ -96,7 +101,8 @@ impl Updater { clear_whole_line(); move_to_col(1); eprint!( - "Checking playlist {}...", + "({}/{total_number}) Checking playlist {}...", + REACHED_NUMBER.fetch_add(1, std::sync::atomic::Ordering::Relaxed), sub.name ); move_to_col(1); |