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
+9 -9
View File
@@ -97,9 +97,9 @@ pub struct ClientSettings {
pub server_address: PeerAddress,
pub enable_listen: bool,
pub listen_port: u16,
/// Directory whose files are shared with (uploaded to) other peers.
/// `None` means nothing is shared.
pub shared_directory: Option<String>,
/// Directories whose files are shared with (uploaded to) other peers.
/// Empty means nothing is shared.
pub shared_directories: Vec<String>,
}
impl ClientSettings {
@@ -126,7 +126,7 @@ impl Default for ClientSettings {
),
enable_listen: true,
listen_port: DEFAULT_LISTEN_PORT,
shared_directory: None,
shared_directories: Vec::new(),
}
}
}
@@ -617,7 +617,7 @@ pub struct Client {
address: PeerAddress,
username: String,
password: String,
shared_directory: Option<String>,
shared_directories: Vec<String>,
server_handle: Option<ActorHandle<ServerMessage>>,
context: Arc<RwLock<ClientContext>>,
}
@@ -639,16 +639,16 @@ impl Client {
address: settings.server_address,
username: settings.username,
password: settings.password,
shared_directory: settings.shared_directory,
shared_directories: settings.shared_directories,
context: Arc::new(RwLock::new(ClientContext::new())),
server_handle: None,
}
}
/// The directory whose files are shared with other peers, if configured.
/// The directories whose files are shared with other peers.
#[must_use]
pub fn shared_directory(&self) -> Option<&str> {
self.shared_directory.as_deref()
pub fn shared_directories(&self) -> &[String] {
&self.shared_directories
}
}