P1: AsyncSmbVfs implementation (Phase 4)

- AsyncSmbVfs: spawn_blocking wrapper over SmbVfs
- AsyncSmbFile: tokio::sync::Mutex for async state
- Add Clone derive to SmbVfs (Arc<Mutex<Tree>>)
- Remove manual Clone impl (derive handles it)

Phase 4 complete: AsyncSmbVfs working
Phase 5 pending: WebDAV integration

Tests: 293 passed, 0 failed
This commit is contained in:
Warren
2026-06-21 21:16:50 +08:00
parent 5c9b51fc49
commit 94a7584e64
3 changed files with 265 additions and 12 deletions
+3 -12
View File
@@ -39,10 +39,11 @@ fn map_smb_error(e: smb2::Error) -> VfsError {
}
/// SMB 客户端 VFS 后端 (SMB 2/3)
#[derive(Clone)]
pub struct SmbVfs {
runtime: Arc<tokio::runtime::Runtime>,
client: Arc<Mutex<smb2::SmbClient>>,
tree: Mutex<smb2::Tree>,
tree: Arc<Mutex<smb2::Tree>>,
}
impl SmbVfs {
@@ -90,7 +91,7 @@ impl SmbVfs {
Ok(Self {
runtime,
client: Arc::new(Mutex::new(client)),
tree: Mutex::new(tree),
tree: Arc::new(Mutex::new(tree)),
})
}
@@ -100,16 +101,6 @@ impl SmbVfs {
}
}
impl Clone for SmbVfs {
fn clone(&self) -> Self {
Self {
runtime: self.runtime.clone(),
client: self.client.clone(),
tree: Mutex::new(self.tree.lock().unwrap().clone()),
}
}
}
impl VfsBackend for SmbVfs {
fn clone_boxed(&self) -> Box<dyn VfsBackend> {
Box::new(self.clone())