smart mirroring

This commit is contained in:
JMARyA 2025-01-13 11:39:00 +01:00
parent 68cb32f07b
commit 7647616242
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
13 changed files with 701 additions and 67 deletions

30
src/config.rs Normal file
View file

@ -0,0 +1,30 @@
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize, Default)]
pub struct Config {
pub mirror: Option<MirrorConfig>,
}
#[derive(Debug, Clone, Deserialize, Default)]
pub struct MirrorConfig {
repos: Vec<String>,
mirrorlist: Vec<String>,
}
impl Config {
pub fn is_mirrored_repo(&self, repo: &str) -> bool {
if let Some(mirrorc) = &self.mirror {
return mirrorc.repos.iter().any(|x| x == repo);
}
false
}
pub fn mirrorlist(&self) -> Option<&[String]> {
if let Some(mirror) = &self.mirror {
return Some(mirror.mirrorlist.as_slice());
}
None
}
}