summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-03-04 13:37:12 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-03-04 13:37:12 +0100
commit248c28c0b882930908493af94f714ce4de3706ac (patch)
tree12e51e389716ba1ea4626d3a222bc4ce83a657cf
parent5b46db841f74663c896c37e5f40a4ad08699ba2b (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>
-rw-r--r--src/commands/build.rs4
-rw-r--r--src/commands/find_artifact.rs4
-rw-r--r--src/main.rs26
3 files changed, 2 insertions, 32 deletions
diff --git a/src/commands/build.rs b/src/commands/build.rs
index 421f7ee..9880552 100644
--- a/src/commands/build.rs
+++ b/src/commands/build.rs
@@ -57,7 +57,6 @@ pub async fn build(
config: &Configuration,
repo: Repository,
repo_path: &Path,
- max_packages: u64,
) -> Result<()> {
use crate::db::models::{EnvVar, GitHash, Image, Job, Package, Submit};
@@ -159,7 +158,6 @@ pub async fn build(
.iter()
.map(|storename| {
let bar_release_loading = progressbars.bar();
- bar_release_loading.set_length(max_packages);
let p = config.releases_directory().join(storename);
debug!("Loading release directory: {}", p.display());
@@ -175,7 +173,6 @@ pub async fn build(
let (staging_store, staging_dir, submit_id) = {
let bar_staging_loading = progressbars.bar();
- bar_staging_loading.set_length(max_packages);
let (submit_id, p) = if let Some(staging_dir) = matches.value_of("staging_dir").map(PathBuf::from) {
info!(
@@ -219,7 +216,6 @@ pub async fn build(
let dag = {
let bar_tree_building = progressbars.bar();
- bar_tree_building.set_length(max_packages);
let dag = Dag::for_root_package(package.clone(), &repo, &bar_tree_building)?;
bar_tree_building.finish_with_message("Finished loading Dag");
dag
diff --git a/src/commands/find_artifact.rs b/src/commands/find_artifact.rs
index 469fb6e..ee11229 100644
--- a/src/commands/find_artifact.rs
+++ b/src/commands/find_artifact.rs
@@ -30,7 +30,7 @@ use crate::repository::Repository;
use crate::util::progress::ProgressBars;
/// Implementation of the "find_artifact" subcommand
-pub async fn find_artifact(matches: &ArgMatches, config: &Configuration, progressbars: ProgressBars, repo: Repository, database_connection: PgConnection, max_packages: u64) -> Result<()> {
+pub async fn find_artifact(matches: &ArgMatches, config: &Configuration, progressbars: ProgressBars, repo: Repository, database_connection: PgConnection) -> Result<()> {
let package_name_regex = crate::commands::util::mk_package_name_regex({
matches.value_of("package_name_regex").unwrap() // safe by clap
})?;
@@ -55,7 +55,6 @@ pub async fn find_artifact(matches: &ArgMatches, config: &Configuration, progres
.iter()
.map(|storename| {
let bar_release_loading = progressbars.bar();
- bar_release_loading.set_length(max_packages);
let p = config.releases_directory().join(storename);
debug!("Loading release directory: {}", p.display());
@@ -72,7 +71,6 @@ pub async fn find_artifact(matches: &ArgMatches, config: &Configuration, progres
let staging_store = if let Some(p) = matches.value_of("staging_dir").map(PathBuf::from) {
let bar_staging_loading = progressbars.bar();
- bar_staging_loading.set_length(max_packages);
if !p.is_dir() {
let _ = tokio::fs::create_dir_all(&p).await?;
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};