|
@@ -317,7 +317,11 @@ pub async fn run(config: &crate::config::Config, cmd: &ReposCommands, dry_run: b
|
|
|
println!("{:<52} {:<22} {:<18} {n}", repo.url, state, last);
|
|
println!("{:<52} {:<22} {:<18} {n}", repo.url, state, last);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- ReposCommands::Sync { force } => {
|
|
|
|
|
|
|
+ ReposCommands::Sync {
|
|
|
|
|
+ force,
|
|
|
|
|
+ watch,
|
|
|
|
|
+ interval,
|
|
|
|
|
+ } => {
|
|
|
let force = *force;
|
|
let force = *force;
|
|
|
if dry_run {
|
|
if dry_run {
|
|
|
for repo in &config.recipe_repos {
|
|
for repo in &config.recipe_repos {
|
|
@@ -336,15 +340,28 @@ pub async fn run(config: &crate::config::Config, cmd: &ReposCommands, dry_run: b
|
|
|
}
|
|
}
|
|
|
return Ok(());
|
|
return Ok(());
|
|
|
}
|
|
}
|
|
|
- let reg_path = registry_path().unwrap_or_else(|| PathBuf::from("repos.json"));
|
|
|
|
|
- let reg = load_registry(®_path);
|
|
|
|
|
- let base = cache_base();
|
|
|
|
|
- let repos = config.recipe_repos.clone();
|
|
|
|
|
- let roots = tokio::task::spawn_blocking(move || sync_repos(&repos, &base, ®, force))
|
|
|
|
|
- .await
|
|
|
|
|
- .unwrap_or_default();
|
|
|
|
|
- if roots.is_empty() {
|
|
|
|
|
- warn!("{}", fluent_i18n::t!("repos-none-synced"));
|
|
|
|
|
|
|
+ let interval_min = *interval;
|
|
|
|
|
+ loop {
|
|
|
|
|
+ let reg_path = registry_path().unwrap_or_else(|| PathBuf::from("repos.json"));
|
|
|
|
|
+ let reg = load_registry(®_path);
|
|
|
|
|
+ let base = cache_base();
|
|
|
|
|
+ let repos = config.recipe_repos.clone();
|
|
|
|
|
+ let n = repos.len();
|
|
|
|
|
+ let roots =
|
|
|
|
|
+ tokio::task::spawn_blocking(move || sync_repos(&repos, &base, ®, force))
|
|
|
|
|
+ .await
|
|
|
|
|
+ .unwrap_or_default();
|
|
|
|
|
+ if roots.is_empty() {
|
|
|
|
|
+ warn!("{}", fluent_i18n::t!("repos-none-synced"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if !watch {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ info!(
|
|
|
|
|
+ "{}",
|
|
|
|
|
+ fluent_i18n::t!("recipe-repo-watch", { "n" => n, "interval" => interval_min })
|
|
|
|
|
+ );
|
|
|
|
|
+ tokio::time::sleep(std::time::Duration::from_secs(interval_min as u64 * 60)).await;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|