This commit is contained in:
parent
d1882114c7
commit
bd589d8b45
15 changed files with 221 additions and 12 deletions
|
@ -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)),
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue