smart mirroring
This commit is contained in:
parent
68cb32f07b
commit
7647616242
13 changed files with 701 additions and 67 deletions
30
src/config.rs
Normal file
30
src/config.rs
Normal 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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue