feat: multiple shared directories

Shares::scan_many merges several roots into one index, suffixing
duplicate root names so virtual paths cannot collide, and skipping
unreadable roots instead of failing. ClientSettings now takes
shared_directories: Vec<String>; config gains a shared_dirs list
(combined with the single shared_dir and --shared-dir, deduped), with an
explicitly empty value still disabling sharing and the
share-what-you-download default unchanged.
This commit is contained in:
michel
2026-07-20 20:47:23 +02:00
parent 8389d525e7
commit a605431a10
9 changed files with 277 additions and 117 deletions
+14
View File
@@ -35,6 +35,20 @@ pub fn resolve_shared_directory(
Ok(Some(path))
}
/// Validate several configured share paths; invalid ones are skipped with a
/// warning instead of aborting (the client just shares less).
pub fn resolve_shared_directories(dirs: &[String]) -> Vec<String> {
let mut resolved = Vec::new();
for dir in dirs {
match resolve_shared_directory(Some(dir)) {
Ok(Some(path)) => resolved.push(path.display().to_string()),
Ok(None) => {}
Err(e) => eprintln!("⚠️ Ignoring shared directory: {e}"),
}
}
resolved
}
#[cfg(test)]
mod tests {
use super::resolve_shared_directory;