Implement SMB Previous versions (shadow copy) at VFS layer
- Add VfsPreviousVersion struct (snapshot_name, gmt_token, created, size) - Add VfsBackend methods: - list_previous_versions() - enumerate snapshot versions - open_previous_version() - open file from snapshot by GMT token - restore_previous_version() - restore file from snapshot - LocalFs implementation: - systemtime_to_gmt_token() - convert SystemTime to @GMT-YYYY.MM.DD-HH.MM.SS - scan .snapshots directory for matching versions - use existing restore_snapshot() for restoration - Foundation for SMB shadow copy (@GMT- token support) All 229 tests pass.
This commit is contained in:
@@ -218,6 +218,23 @@ pub trait VfsBackend: Send + Sync {
|
||||
fn check_quota(&self, _path: &Path, _size: u64) -> Result<bool, VfsError> {
|
||||
Ok(true) // Default: no quota, always allow
|
||||
}
|
||||
|
||||
// ===== Previous versions (shadow copy) =====
|
||||
|
||||
/// 列出文件的所有历史版本
|
||||
fn list_previous_versions(&self, _path: &Path) -> Result<Vec<VfsPreviousVersion>, VfsError> {
|
||||
Err(VfsError::Unsupported("list_previous_versions".to_string()))
|
||||
}
|
||||
|
||||
/// 打开历史版本文件(通过 @GMT- token)
|
||||
fn open_previous_version(&self, _path: &Path, _gmt_token: &str) -> Result<Box<dyn VfsFile>, VfsError> {
|
||||
Err(VfsError::Unsupported("open_previous_version".to_string()))
|
||||
}
|
||||
|
||||
/// 从历史版本恢复文件
|
||||
fn restore_previous_version(&self, _path: &Path, _gmt_token: &str) -> Result<(), VfsError> {
|
||||
Err(VfsError::Unsupported("restore_previous_version".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// 快照信息
|
||||
@@ -261,6 +278,19 @@ pub struct VfsQuotaUsage {
|
||||
pub over_hard_limit: bool,
|
||||
}
|
||||
|
||||
/// 历史版本信息(SMB shadow copy)
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct VfsPreviousVersion {
|
||||
/// 快照名称
|
||||
pub snapshot_name: String,
|
||||
/// GMT token (@GMT-YYYY.MM.DD-HH.MM.SS)
|
||||
pub gmt_token: String,
|
||||
/// 创建时间
|
||||
pub created: SystemTime,
|
||||
/// 版本大小(字节)
|
||||
pub size: u64,
|
||||
}
|
||||
|
||||
/// 压缩算法类型
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum VfsCompression {
|
||||
|
||||
Reference in New Issue
Block a user