feat: new stuff
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Strix 2023-10-14 22:39:52 +02:00
parent d1882114c7
commit bd589d8b45
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774
15 changed files with 221 additions and 12 deletions

View file

@ -22,4 +22,16 @@ impl Default for Repo {
#[derive(Clone, Serialize, Deserialize)]
pub struct RepoFile {
pub repos: HashMap<String, Repo>
}
impl RepoFile {
pub fn from_path(path: &str) -> Result<RepoFile, String> {
match std::fs::read_to_string(path) {
Ok(s) => match toml::from_str(&s) {
Ok(c) => Ok(c),
Err(e) => Err(format!("failed to parse config: {}", e)),
},
Err(e) => Err(format!("failed to read config: {}", e)),
}
}
}

View file

@ -7,7 +7,10 @@ pub struct Storage {
pub repo_file: String,
/// Where to store pkgs data
#[serde(default)]
pub data_dir: String
pub data_dir: String,
/// Where to store repo indexes
#[serde(default)]
pub index_dir: String,
}
impl Default for Storage {
@ -15,6 +18,7 @@ impl Default for Storage {
Storage {
repo_file: String::from("/etc/pkgr.d/repos.toml"),
data_dir: String::from("/var/lib/pkgr/packages"),
index_dir: String::from("/var/lib/pkgr/indexes"),
}
}
}