summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-12-09 17:18:35 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-12-09 17:23:55 +0100
commite91869e46fc39e1a6e91dce5c603911fcaad10f5 (patch)
treeaceb1d697384347d6991b4d70f50a18a21f6ad15 /src
parent2205057859f8321496a8a800c242c6cd82fef168 (diff)
Fix weird rendering bug of progress bars
Apparently, this fixes the rendering bug we had with indicatif. The issue was, that we called `indicatif::ProgressBar::set_message()` before the bar was added to the `indicatif::MultiProgress` object. This caused the bar to be rendered, and as soon we added it to the MultiProgress object and re-called set_message(), it was rendered again. This is of course a bug / inconveniance in indicatif. Either way, the issue was solved by not calling `set_message()` in our `ProgressBars` helper object, but only return a preconfigured bar object. Because not calling the set_message() function yields the whole bunch of helper functions as unnecessary, these were removed and the interface was boiled down to `pub fn ProgressBars::bar(&self) -> indicatif::ProgressBar` which in turn results in a few modifications all over the place. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r--src/commands/build.rs6
-rw-r--r--src/commands/source.rs6
-rw-r--r--src/main.rs6
-rw-r--r--src/orchestrator/orchestrator.rs2
-rw-r--r--src/util/progress.rs49
5 files changed, 15 insertions, 54 deletions
diff --git a/src/commands/build.rs b/src/commands/build.rs
index 7d7f96a..b83d790 100644
--- a/src/commands/build.rs
+++ b/src/commands/build.rs
@@ -122,7 +122,7 @@ pub async fn build(matches: &ArgMatches,
let package = *packages.get(0).ok_or_else(|| anyhow!("Found no package."))?;
let release_dir = {
- let bar_release_loading = progressbars.release_loading();
+ let bar_release_loading = progressbars.bar();
bar_release_loading.set_length(max_packages);
let p = config.releases_directory();
@@ -137,7 +137,7 @@ pub async fn build(matches: &ArgMatches,
};
let (staging_store, staging_dir) = {
- let bar_staging_loading = progressbars.staging_loading();
+ let bar_staging_loading = progressbars.bar();
bar_staging_loading.set_length(max_packages);
let p = if let Some(staging_dir) = matches.value_of("staging_dir").map(PathBuf::from) {
@@ -164,7 +164,7 @@ pub async fn build(matches: &ArgMatches,
};
let tree = {
- let bar_tree_building = progressbars.tree_building();
+ let bar_tree_building = progressbars.bar();
bar_tree_building.set_length(max_packages);
let mut tree = Tree::new();
diff --git a/src/commands/source.rs b/src/commands/source.rs
index c4ad11a..1906b13 100644
--- a/src/commands/source.rs
+++ b/src/commands/source.rs
@@ -53,7 +53,8 @@ pub (in crate::commands) async fn verify_impl<'a, I>(packages: I, sc: &SourceCac
.flatten()
.map(|src| (multi.clone(), src))
.map(|(multi, source)| async move {
- let bar = multi.add(progressbars.verification_bar(source.path()));
+ trace!("Verifying: {}", source.path().display());
+ let bar = multi.add(progressbars.bar());
if source.path().exists() {
source.verify_hash()
.await
@@ -150,7 +151,8 @@ pub async fn download(matches: &ArgMatches, config: &Configuration, repo: Reposi
sc.sources_for(p)
.into_iter()
.map(|source| {
- let bar = multi.add(progressbars.download_bar(source.url()));
+ let bar = multi.add(progressbars.spinner());
+ bar.set_message(&format!("Downloading {}", source.url()));
async move {
if source.exists() && !force {
Err(anyhow!("Source exists: {}", source.path().display()))
diff --git a/src/main.rs b/src/main.rs
index 750e3d9..e00014b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -87,7 +87,7 @@ async fn main() -> Result<()> {
let progressbars = ProgressBars::setup(config.progress_format().clone(), config.spinner_format().clone(), hide_bars);
let load_repo = || -> Result<Repository> {
- let bar = progressbars.repo_loading();
+ let bar = progressbars.bar();
bar.set_length(max_packages);
let repo = Repository::load(&repo_path, &bar)?;
bar.finish_with_message("Repository loading finished");
@@ -106,14 +106,14 @@ async fn main() -> Result<()> {
},
Some(("what-depends", matches)) => {
let repo = load_repo()?;
- let bar = progressbars.what_depends();
+ let bar = progressbars.bar();
bar.set_length(max_packages);
crate::commands::what_depends(matches, &config, repo).await?
},
Some(("dependencies-of", matches)) => {
let repo = load_repo()?;
- let bar = progressbars.what_depends();
+ let bar = progressbars.bar();
bar.set_length(max_packages);
crate::commands::dependencies_of(matches, &config, repo).await?
},
diff --git a/src/orchestrator/orchestrator.rs b/src/orchestrator/orchestrator.rs
index eb03c0a..ef12a53 100644
--- a/src/orchestrator/orchestrator.rs
+++ b/src/orchestrator/orchestrator.rs
@@ -101,7 +101,7 @@ impl<'a> Orchestrator<'a> {
.await?
.into_iter()
.map(|runnable| {
- let bar = multibar.add(progress_generator.job_bar(runnable.uuid()));
+ let bar = multibar.add(progress_generator.bar());
Self::run_runnable(runnable, scheduler, bar)
})
.collect::<futures::stream::FuturesUnordered<_>>()
diff --git a/src/util/progress.rs b/src/util/progress.rs
index 5874624..8358dcc 100644
--- a/src/util/progress.rs
+++ b/src/util/progress.rs
@@ -1,8 +1,4 @@
-use std::path::PathBuf;
-
use indicatif::*;
-use uuid::Uuid;
-use url::Url;
#[derive(Clone, Debug)]
pub struct ProgressBars {
@@ -20,59 +16,22 @@ impl ProgressBars {
}
}
- pub fn tree_building(&self) -> ProgressBar {
- self.bar("Building package tree", &self.bar_template)
- }
-
- pub fn repo_loading(&self) -> ProgressBar {
- self.bar("Repository loading", &self.bar_template)
- }
-
- pub fn staging_loading(&self) -> ProgressBar {
- self.bar("Loading staging", &self.bar_template)
- }
-
- pub fn release_loading(&self) -> ProgressBar {
- self.bar("Loading releases", &self.bar_template)
- }
-
- pub fn what_depends(&self) -> ProgressBar {
- self.bar("Crawling dependencies", &self.bar_template)
- }
-
- pub fn job_bar(&self, id: &Uuid) -> ProgressBar {
- let b = self.bar(&format!("Job: {}", id), &self.bar_template);
- b.set_length(100);
- b
- }
-
- pub fn download_bar(&self, url: &Url) -> ProgressBar {
- self.bar(&format!("Download: {}", url.as_str()), &self.bar_template)
- }
-
- pub fn verification_bar(&self, path: PathBuf) -> ProgressBar {
- self.spinner(&self.spinner_template, format!("Verification: {}", path.display()))
- }
-
- fn bar(&self, msg: &str, template: &str) -> ProgressBar {
+ pub fn bar(&self) -> ProgressBar {
if self.hide {
ProgressBar::hidden()
} else {
let b = ProgressBar::new(1);
- b.set_style(ProgressStyle::default_bar().template(template));
- b.set_message(msg);
+ b.set_style(ProgressStyle::default_bar().template(&self.bar_template));
b
}
}
- fn spinner(&self, template: &str, msg: String) -> ProgressBar {
+ pub fn spinner(&self) -> ProgressBar {
if self.hide {
ProgressBar::hidden()
} else {
let bar = ProgressBar::new_spinner();
- bar.set_style(ProgressStyle::default_spinner().template(template));
- bar.enable_steady_tick(100);
- bar.set_message(&msg);
+ bar.set_style(ProgressStyle::default_spinner().template(&self.spinner_template));
bar
}
}