@@ -59,31 +59,60 @@ pub async fn resolve_host(host_id: String) -> Option<NetworkHost> {
5959
6060/// Lists shares available on a network host.
6161///
62- /// Returns cached results if available (30 second TTL) , otherwise queries the host.
62+ /// Returns cached results if available, otherwise queries the host.
6363/// Attempts guest access first; returns an error if authentication is required.
6464///
6565/// # Arguments
6666/// * `host_id` - Unique identifier for the host (used for caching)
6767/// * `hostname` - Hostname to connect to (for example, "TEST_SERVER.local")
6868/// * `ip_address` - Optional resolved IP address (preferred over hostname for reliability)
6969/// * `port` - SMB port (default 445, but Docker containers may use different ports)
70+ /// * `timeout_ms` - Optional timeout in milliseconds (default: 15000)
71+ /// * `cache_ttl_ms` - Optional cache TTL in milliseconds (default: 30000)
7072#[ tauri:: command]
7173pub async fn list_shares_on_host (
7274 host_id : String ,
7375 hostname : String ,
7476 ip_address : Option < String > ,
7577 port : u16 ,
78+ timeout_ms : Option < u64 > ,
79+ cache_ttl_ms : Option < u64 > ,
7680) -> Result < ShareListResult , ShareListError > {
77- smb_client:: list_shares ( & host_id, & hostname, ip_address. as_deref ( ) , port, None ) . await
81+ smb_client:: list_shares (
82+ & host_id,
83+ & hostname,
84+ ip_address. as_deref ( ) ,
85+ port,
86+ None ,
87+ timeout_ms,
88+ cache_ttl_ms,
89+ )
90+ . await
7891}
7992
8093/// Prefetches shares for a host (for example, on hover).
8194/// Same as list_shares_on_host but designed for prefetching - errors are silently ignored.
8295/// Returns immediately if shares are already cached.
8396#[ tauri:: command]
84- pub async fn prefetch_shares ( host_id : String , hostname : String , ip_address : Option < String > , port : u16 ) {
97+ pub async fn prefetch_shares (
98+ host_id : String ,
99+ hostname : String ,
100+ ip_address : Option < String > ,
101+ port : u16 ,
102+ timeout_ms : Option < u64 > ,
103+ cache_ttl_ms : Option < u64 > ,
104+ ) {
85105 // Fire and forget - we don't care about the result for prefetching
86- let _ = smb_client:: list_shares ( & host_id, & hostname, ip_address. as_deref ( ) , port, None ) . await ;
106+ let _ = smb_client:: list_shares (
107+ & host_id,
108+ & hostname,
109+ ip_address. as_deref ( ) ,
110+ port,
111+ None ,
112+ timeout_ms,
113+ cache_ttl_ms,
114+ )
115+ . await ;
87116}
88117
89118/// Gets auth mode detected for a host (from cached share list if available).
@@ -189,14 +218,22 @@ pub fn delete_smb_credentials(server: String, share: Option<String>) -> Result<(
189218/// * `port` - SMB port
190219/// * `username` - Username for authentication (or None for guest)
191220/// * `password` - Password for authentication (or None for guest)
221+ /// * `timeout_ms` - Optional timeout in milliseconds (default: 15000)
222+ /// * `cache_ttl_ms` - Optional cache TTL in milliseconds (default: 30000)
192223#[ tauri:: command]
224+ #[ allow(
225+ clippy:: too_many_arguments,
226+ reason = "Tauri command requires all parameters to be top-level"
227+ ) ]
193228pub async fn list_shares_with_credentials (
194229 host_id : String ,
195230 hostname : String ,
196231 ip_address : Option < String > ,
197232 port : u16 ,
198233 username : Option < String > ,
199234 password : Option < String > ,
235+ timeout_ms : Option < u64 > ,
236+ cache_ttl_ms : Option < u64 > ,
200237) -> Result < ShareListResult , ShareListError > {
201238 let credentials = match ( username, password) {
202239 ( Some ( u) , Some ( p) ) => Some ( ( u, p) ) ,
@@ -209,6 +246,8 @@ pub async fn list_shares_with_credentials(
209246 ip_address. as_deref ( ) ,
210247 port,
211248 credentials. as_ref ( ) . map ( |( u, p) | ( u. as_str ( ) , p. as_str ( ) ) ) ,
249+ timeout_ms,
250+ cache_ttl_ms,
212251 )
213252 . await
214253}
@@ -228,6 +267,7 @@ use crate::network::mount::{self, MountError, MountResult};
228267/// * `share` - Name of the share to mount
229268/// * `username` - Optional username for authentication
230269/// * `password` - Optional password for authentication
270+ /// * `timeout_ms` - Optional timeout in milliseconds (default: 20000)
231271///
232272/// # Returns
233273/// * `Ok(MountResult)` - Mount successful, with path to mount point
@@ -238,6 +278,7 @@ pub async fn mount_network_share(
238278 share : String ,
239279 username : Option < String > ,
240280 password : Option < String > ,
281+ timeout_ms : Option < u64 > ,
241282) -> Result < MountResult , MountError > {
242- mount:: mount_share ( server, share, username, password) . await
283+ mount:: mount_share ( server, share, username, password, timeout_ms ) . await
243284}
0 commit comments