diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-03-04 13:37:12 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-03-04 13:37:12 +0100 |
commit | 248c28c0b882930908493af94f714ce4de3706ac (patch) | |
tree | 12e51e389716ba1ea4626d3a222bc4ce83a657cf /src/main.rs | |
parent | 5b46db841f74663c896c37e5f40a4ad08699ba2b (diff) |
Remove counting of package files
This removes the counting of package files and using that value to set
the length of the progress bar.
This was just overhead and because of the duration of the bars to be
visible (very short) simply not necessary.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/src/main.rs b/src/main.rs index 1c1f838..b43a401 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,14 +48,12 @@ extern crate log as logcrate; #[macro_use] extern crate diesel; -use std::path::Path; use std::path::PathBuf; use anyhow::anyhow; use anyhow::Result; use clap::ArgMatches; use logcrate::debug; -use walkdir::WalkDir; use rand as _; // Required to make lints happy use aquamarine as _; // doc-helper crate use funty as _; // doc-helper crate @@ -102,7 +100,6 @@ async fn main() -> Result<()> { let config = config.try_into::<NotValidatedConfiguration>()?.validate()?; - let max_packages = count_pkg_files(&repo_path); let hide_bars = cli.is_present("hide_bars") || crate::util::stdout_is_pipe(); let progressbars = ProgressBars::setup( config.progress_format().clone(), @@ -112,7 +109,6 @@ async fn main() -> Result<()> { let load_repo = || -> Result<Repository> { let bar = progressbars.bar(); - bar.set_length(max_packages); let repo = Repository::load(&repo_path, &bar)?; bar.finish_with_message("Repository loading finished"); Ok(repo) @@ -135,21 +131,16 @@ async fn main() -> Result<()> { &config, repo, &repo_path, - max_packages, ) .await? } Some(("what-depends", matches)) => { let repo = load_repo()?; - 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.bar(); - bar.set_length(max_packages); crate::commands::dependencies_of(matches, &config, repo).await? } @@ -166,7 +157,7 @@ async fn main() -> Result<()> { Some(("find-artifact", matches)) => { let repo = load_repo()?; let conn = crate::db::establish_connection(db_connection_config)?; - crate::commands::find_artifact(matches, &config, progressbars, repo, conn, max_packages).await? + crate::commands::find_artifact(matches, &config, progressbars, repo, conn).await? } Some(("find-pkg", matches)) => { @@ -200,21 +191,6 @@ async fn main() -> Result<()> { Ok(()) } -fn count_pkg_files(p: &Path) -> u64 { - WalkDir::new(p) - .follow_links(true) - .into_iter() - .filter_map(Result::ok) - .filter(|d| d.file_type().is_file()) - .filter(|f| { - f.path() - .file_name() - .map(|name| name == "pkg.toml") - .unwrap_or(false) - }) - .count() as u64 -} - fn generate_completions(matches: &ArgMatches) { use clap_generate::generate; use clap_generate::generators::{Bash, Elvish, Fish, Zsh}; |