Skip to content

Commit

Permalink
Add multi-root option
Browse files Browse the repository at this point in the history
  • Loading branch information
Stridsvagn69420 committed Nov 14, 2022
1 parent c08a02b commit a6fdf19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ pub struct Config {
/// The display name of the repository.
pub name: String,

/// File root
/// File roots
///
/// The file root where all albums are stored.
pub root: String,
/// The file roots where all albums are stored.
pub root: Vec<String>,

/// UUIDv4
///
Expand Down Expand Up @@ -85,7 +85,7 @@ impl From<Hostinfo> for Config {
fn from(x: Hostinfo) -> Config {
Config {
name: x.name,
root: "".to_string(),
root: Vec::new(),
uuid: x.uuid,
icon: x.icon,
htpasswd: None,
Expand Down
6 changes: 5 additions & 1 deletion src/hostinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ impl Hostinfo {
///
/// Generates a Hostinfo based on a [Config].
pub fn generate(cfg: Config) -> io::Result<Hostinfo> {
let albums = Hostinfo::read_albums(cfg.root.as_str())?;
let mut albums: Vec<Album> = Vec::new();
for rootpath in &cfg.root {
let album_slice = Hostinfo::read_albums(rootpath)?;
albums.extend(album_slice);
}
let mut hostinfo = Hostinfo::from(cfg);
hostinfo.size = albums.iter().map(|x| x.size).sum();
hostinfo.albums = albums;
Expand Down

0 comments on commit a6fdf19

Please sign in to comment.