summaryrefslogtreecommitdiffstats
path: root/src/repository/repository.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-10-12 20:13:25 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-10-12 20:13:25 +0200
commitf0cb51a046cf563cbd2fede847bf076e475c2bc8 (patch)
tree8d3140da3c8742af4f4b896d924aaa18bccb9cf6 /src/repository/repository.rs
parente46346bddd46f1f771d5dcb4f47011b39c9ec630 (diff)
Add progress reporting to repository loading mechanism
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/repository/repository.rs')
-rw-r--r--src/repository/repository.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/repository/repository.rs b/src/repository/repository.rs
index 8997e6a..e6a52d2 100644
--- a/src/repository/repository.rs
+++ b/src/repository/repository.rs
@@ -17,7 +17,7 @@ pub struct Repository {
impl Repository {
- pub fn load(path: &Path) -> Result<Self> {
+ pub fn load(path: &Path, progress: &indicatif::ProgressBar) -> Result<Self> {
fn all_subdirs(p: &Path) -> Result<Vec<PathBuf>> {
let mut v = Vec::new();
for de in p.read_dir()? {
@@ -30,7 +30,7 @@ impl Repository {
return Ok(v)
}
- fn load_recursive(path: &Path, mut config: config::Config) -> Result<Vec<Result<Package>>> {
+ fn load_recursive(path: &Path, mut config: config::Config, progress: &indicatif::ProgressBar) -> Result<Vec<Result<Package>>> {
let pkg_file = path.join("pkg.toml");
if pkg_file.is_file() {
@@ -48,13 +48,14 @@ impl Repository {
.deserialize()
.with_context(|| format!("Failed to parse {} into package", path.display()));
+ progress.tick();
Ok(vec![package])
} else {
subdirs
.into_iter()
.fold(Ok(Vec::new()), |vec, dir| {
vec.and_then(|mut v| {
- let mut loaded = load_recursive(&dir, config.clone())
+ let mut loaded = load_recursive(&dir, config.clone(), progress)
.with_context(|| format!("Recursing for {}", pkg_file.display()))?;
v.append(&mut loaded);
@@ -64,7 +65,7 @@ impl Repository {
}
}
- let inner = load_recursive(path, config::Config::default())
+ let inner = load_recursive(path, config::Config::default(), progress)
.with_context(|| format!("Recursing for {}", path.display()))?
.into_iter()
.map_ok(|p| ((p.name().clone(), p.version().clone()), p))