Phase 5: WebDAV async integration analysis - API mismatch found
- dav-server DavFileSystem API changed (20+ compile errors) - read_dir takes ReadDirMeta, not depth - have_props/get_props/get_prop/patch_props new methods - DavFile needs write_buf method - DavMetaData/DavDirEntry async return types changed Recommended approach: spawn_blocking wrapper (~2h) Alternative: full rewrite (~8h) Phase 5 blocked pending API analysis
This commit is contained in:
@@ -632,48 +632,36 @@ pub trait AsyncVfsBackend: Send + Sync {
|
||||
// 1. dav-server DavFileSystem trait 方法返回 Pin<Box<dyn Future>>
|
||||
// 2. 当前 VfsDavFs::open() 返回 Box::pin(ready(...))
|
||||
// 3. 这是 "同步包装为 Future",不是真正的 async
|
||||
// 4. DavFileSystem trait API 已变化(2026-06-21 session发现)
|
||||
// - read_dir(path, ReadDirMeta) 而非 read_dir(path, depth)
|
||||
// - have_props(path) 返回 Pin<Box<dyn Future>>
|
||||
// - get_props/get_prop/patch_props 新方法
|
||||
// - get_quota/set_accessed/set_modified 新方法
|
||||
// - DavFile 需要 write_buf 方法
|
||||
// - DavMetaData modified()/is_dir() 返回 Pin<Box<dyn Future>>
|
||||
// - DavDirEntry name()/is_dir()/metadata() 返回 Pin<Box<dyn Future>>
|
||||
//
|
||||
// Phase 5 目标:
|
||||
// 1. AsyncVfsDavFs 使用 AsyncVfsBackend
|
||||
// 2. open() 调用 AsyncVfsBackend::open_file().await
|
||||
// 3. read_dir() 调用 AsyncVfsBackend::read_dir().await
|
||||
// Phase 5 阻塞因素:
|
||||
// 1. dav-server API 签名与预期不匹配(20+ 编译错误)
|
||||
// 2. 需要 match 完整 DavFileSystem trait 所有方法(~30个)
|
||||
// 3. AsyncVfsFile trait 方法签名需调整
|
||||
// 4. 估算工作量:~8小时(而非原估计3小时)
|
||||
//
|
||||
// 实现步骤:
|
||||
// 1. 创建 AsyncVfsDavFs 结构体
|
||||
// 2. 创建 AsyncVfsDavFile 结构体(包装 AsyncVfsFile)
|
||||
// 3. 实现 DavFileSystem trait(调用 AsyncVfsBackend)
|
||||
// 实现方案选择:
|
||||
// 方案A:spawn_blocking wrapper(推荐)
|
||||
// - 创建 AsyncVfsDavFs 包装现有 VfsDavFs
|
||||
// - 所有 DavFileSystem 方法使用 spawn_blocking 调用同步版本
|
||||
// - 工作量:~2小时
|
||||
// - 优点:快速实现,兼容现有 API
|
||||
// - 缺点:仍为伪异步(阻塞线程池)
|
||||
//
|
||||
// 关键代码模式:
|
||||
// ```rust
|
||||
// impl DavFileSystem for AsyncVfsDavFs {
|
||||
// fn open<'a>(&'a self, path: &'a DavPath, options: OpenOptions) -> FsFuture<'a, Box<dyn DavFile>> {
|
||||
// Box::pin(async move {
|
||||
// let vfs_path = self.resolve_path(path)?;
|
||||
// let flags = OpenFlags::from_open_options(&options);
|
||||
// let file = AsyncVfsBackend::open_file(&*self.vfs, &vfs_path, &flags).await?;
|
||||
// Ok(Box::new(AsyncVfsDavFile::new(file)) as Box<dyn DavFile>)
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
// 方案B:完整重写 DavFileSystem(长期)
|
||||
// - 完全匹配 dav-server API
|
||||
// - 使用真正的 AsyncVfsBackend async 方法
|
||||
// - 工作量:~8小时
|
||||
// - 优点:真正的异步
|
||||
// - 缺点:需要完全理解 dav-server API
|
||||
//
|
||||
// AsyncVfsDavFile 实现:
|
||||
// ```rust
|
||||
// pub struct AsyncVfsDavFile {
|
||||
// inner: Box<dyn AsyncVfsFile>,
|
||||
// position: u64,
|
||||
// }
|
||||
// 推荐方案A(spawn_blocking wrapper)
|
||||
//
|
||||
// impl DavFile for AsyncVfsDavFile {
|
||||
// fn read_bytes(&mut self, count: usize) -> FsFuture<'_, Bytes> {
|
||||
// Box::pin(async move {
|
||||
// let mut buf = vec![0u8; count];
|
||||
// let n = AsyncVfsFile::read(&mut self.inner, &mut buf).await?;
|
||||
// buf.truncate(n);
|
||||
// Ok(Bytes::from(buf))
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// 预估工作量:Phase 5 ~3 hours
|
||||
// 预估工作量:Phase 5 方案A ~2小时,方案B ~8小时
|
||||
|
||||
Reference in New Issue
Block a user