Implement VFS snapshot support (ZFS-style)
- Add VfsSnapshotInfo struct - Add snapshot methods to VfsBackend trait: - create_snapshot: copy-on-write with metadata - list_snapshots: enumerate snapshots - delete_snapshot: remove snapshot and metadata - restore_snapshot: restore from snapshot - snapshot_info: get snapshot metadata - Implement LocalFs snapshot support: - Uses .snapshots directory for storage - JSON metadata files (*.meta) - Recursive directory copy - Size calculation This enables SMB 'Previous versions' feature foundation. All 229 tests pass.
This commit is contained in:
@@ -168,4 +168,44 @@ pub trait VfsBackend: Send + Sync {
|
||||
|
||||
/// 创建硬链接
|
||||
fn hard_link(&self, original: &Path, link: &Path) -> Result<(), VfsError>;
|
||||
|
||||
// ===== Snapshot support (ZFS-style) =====
|
||||
|
||||
/// 创建快照
|
||||
fn create_snapshot(&self, _path: &Path, _name: &str) -> Result<(), VfsError> {
|
||||
Err(VfsError::Unsupported("create_snapshot".to_string()))
|
||||
}
|
||||
|
||||
/// 列出快照
|
||||
fn list_snapshots(&self, _path: &Path) -> Result<Vec<String>, VfsError> {
|
||||
Err(VfsError::Unsupported("list_snapshots".to_string()))
|
||||
}
|
||||
|
||||
/// 删除快照
|
||||
fn delete_snapshot(&self, _path: &Path, _name: &str) -> Result<(), VfsError> {
|
||||
Err(VfsError::Unsupported("delete_snapshot".to_string()))
|
||||
}
|
||||
|
||||
/// 从快照恢复
|
||||
fn restore_snapshot(&self, _path: &Path, _name: &str) -> Result<(), VfsError> {
|
||||
Err(VfsError::Unsupported("restore_snapshot".to_string()))
|
||||
}
|
||||
|
||||
/// 获取快照信息
|
||||
fn snapshot_info(&self, _path: &Path, _name: &str) -> Result<VfsSnapshotInfo, VfsError> {
|
||||
Err(VfsError::Unsupported("snapshot_info".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// 快照信息
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct VfsSnapshotInfo {
|
||||
/// 快照名称
|
||||
pub name: String,
|
||||
/// 创建时间
|
||||
pub created: SystemTime,
|
||||
/// 快照大小(字节)
|
||||
pub size: u64,
|
||||
/// 是否只读
|
||||
pub read_only: bool,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user