aboutsummaryrefslogtreecommitdiff
path: root/src/update
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2022-06-07 12:28:18 +0200
committerMaximilian Manz <maximilian.manz@de.clara.net>2022-06-20 11:33:04 +0200
commit7e73ebcad03a5477367763d4a5e9c22f9e9967ca (patch)
tree39e543ec482be2e95c512b45f6dbdbe816dc0992 /src/update
parentfix clippy lints (diff)
process sync and update in parallel
Split the repos up in x batches where x is either decided on based on number of cpu cores available or given by the --jobs argument
Diffstat (limited to 'src/update')
-rw-r--r--src/update/mod.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/update/mod.rs b/src/update/mod.rs
index d2d6494..8f10663 100644
--- a/src/update/mod.rs
+++ b/src/update/mod.rs
@@ -3,20 +3,21 @@ use std::fmt::{Debug, Display};
use git2::BranchType;
use tracing::debug;
-use crate::repo::{Repo, RepoError, Repos};
+use crate::{
+ batch::batch,
+ repo::{Repo, RepoError, Repos},
+};
impl crate::GTree {
pub fn update(&self, repos: Repos) {
- for (_name, repo) in repos {
- let mut repo = repo.write().unwrap();
-
+ batch(repos, |mut repo| {
if repo.repo.is_some() {
match repo.update() {
Ok(u) => println!("{}", u),
Err(u) => println!("{}", u),
};
}
- }
+ });
}
}