diff options
author | Jesse Luehrs <doy@tozt.net> | 2018-11-07 20:57:21 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2018-11-07 20:57:21 -0500 |
commit | d022e0304ffb61ac32891bc097be4abf11025a92 (patch) | |
tree | 52924947811175cb19cdac5a972826e660f7dc2a | |
parent | 669c88a10a0930fd73e8fa5d587b3894aed1924b (diff) | |
download | lastfm-query-d022e0304ffb61ac32891bc097be4abf11025a92.tar.gz lastfm-query-d022e0304ffb61ac32891bc097be4abf11025a92.zip |
don't even try to do work if we know there's nothing to do
-rw-r--r-- | src/cmd/sync.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/cmd/sync.rs b/src/cmd/sync.rs index 7dfb559..985b221 100644 --- a/src/cmd/sync.rs +++ b/src/cmd/sync.rs @@ -15,16 +15,18 @@ pub fn run(opts: &cli::Options) -> failure::Fallible<()> { let from = db.most_recent_timestamp()?.map(|x| x + 1); let to_fetch = lastfm.track_count(from)?; - let bar = indicatif::ProgressBar::new(to_fetch); - bar.set_style( - indicatif::ProgressStyle::default_bar() - .progress_chars("=> ") - .template("Downloading {pos}/{len} tracks...\n{percent:>3}% [{wide_bar}] {eta:5}") - ); + if to_fetch > 0 { + let bar = indicatif::ProgressBar::new(to_fetch); + bar.set_style( + indicatif::ProgressStyle::default_bar() + .progress_chars("=> ") + .template("Downloading {pos}/{len} tracks...\n{percent:>3}% [{wide_bar}] {eta:5}") + ); - db.insert_tracks(bar.wrap_iter(lastfm.tracks(from)))?; + db.insert_tracks(bar.wrap_iter(lastfm.tracks(from)))?; - bar.finish_with_message("done"); + bar.finish_with_message("done"); + } Ok(()) } |