diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-11-20 17:40:22 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-11-20 17:40:22 +0800 |
| commit | 2cba54e5176ef8e6f670dbb552d7333a9f42ae36 (patch) | |
| tree | a9cbfacc3d6c64721137922fae39c13b2ef4a262 | |
| parent | 03335c9816085cde77e0ffbae35e7f85623b7293 (diff) | |
feat: Enhance version tracking in LatestFileData
Extend LatestFileData to track file versions alongside holding status, update method signatures to include version information.
| -rw-r--r-- | crates/vcs_data/src/data/local.rs | 11 | ||||
| -rw-r--r-- | crates/vcs_data/src/data/local/latest_file_data.rs | 21 |
2 files changed, 23 insertions, 9 deletions
diff --git a/crates/vcs_data/src/data/local.rs b/crates/vcs_data/src/data/local.rs index cbf5b73..85d431f 100644 --- a/crates/vcs_data/src/data/local.rs +++ b/crates/vcs_data/src/data/local.rs @@ -13,7 +13,7 @@ use vcs_docs::docs::READMES_LOCAL_WORKSPACE_TODOLIST; use crate::{ constants::{ CLIENT_FILE_LOCAL_SHEET, CLIENT_FILE_TODOLIST, CLIENT_FILE_WORKSPACE, - CLIENT_PATH_LOCAL_SHEET, + CLIENT_PATH_LOCAL_SHEET, CLIENT_SUFFIX_LOCAL_SHEET_FILE, }, current::{current_local_path, find_local_path}, data::{ @@ -29,10 +29,10 @@ use crate::{ pub mod cached_sheet; pub mod config; pub mod file_status; +pub mod latest_file_data; pub mod latest_info; pub mod local_files; pub mod local_sheet; -pub mod member_held; const SHEET_NAME: &str = "{sheet_name}"; const ACCOUNT_NAME: &str = "{account}"; @@ -179,7 +179,12 @@ impl LocalWorkspace { Ok(()) } - collect_sheet_paths(&local_sheet_path, ".json", &mut sheet_paths).await?; + collect_sheet_paths( + &local_sheet_path, + CLIENT_SUFFIX_LOCAL_SHEET_FILE, + &mut sheet_paths, + ) + .await?; Ok(sheet_paths) } } diff --git a/crates/vcs_data/src/data/local/latest_file_data.rs b/crates/vcs_data/src/data/local/latest_file_data.rs index f737650..8a6a3cb 100644 --- a/crates/vcs_data/src/data/local/latest_file_data.rs +++ b/crates/vcs_data/src/data/local/latest_file_data.rs @@ -4,7 +4,7 @@ use cfg_file::ConfigFile; use serde::{Deserialize, Serialize}; use crate::{ - constants::{CLIENT_FILE_MEMBER_HELD, CLIENT_FILE_MEMBER_HELD_NOSET}, + constants::{CLIENT_FILE_LATEST_DATA, CLIENT_FILE_MEMBER_HELD_NOSET}, current::current_local_path, data::{ member::MemberId, @@ -37,14 +37,14 @@ pub enum HeldStatus { impl LatestFileData { /// Get the path to the file holding the held status information for the given member. - pub fn held_file_path(account: &MemberId) -> Result<PathBuf, std::io::Error> { + pub fn data_path(account: &MemberId) -> Result<PathBuf, std::io::Error> { let Some(local_path) = current_local_path() else { return Err(Error::new( std::io::ErrorKind::NotFound, "Workspace not found.", )); }; - Ok(local_path.join(CLIENT_FILE_MEMBER_HELD.replace(ACCOUNT, account))) + Ok(local_path.join(CLIENT_FILE_LATEST_DATA.replace(ACCOUNT, account))) } /// Get the member who holds the file with the given ID. @@ -55,16 +55,25 @@ impl LatestFileData { }) } + /// Get the version of the file with the given ID. + pub fn file_version(&self, vfid: &VirtualFileId) -> Option<&VirtualFileVersion> { + self.versions.get(vfid) + } + /// Update the held status of the files. - pub fn update_held_status(&mut self, map: HashMap<VirtualFileId, Option<MemberId>>) { - for (vfid, member_id) in map { + pub fn update_info( + &mut self, + map: HashMap<VirtualFileId, (Option<MemberId>, VirtualFileVersion)>, + ) { + for (vfid, (member_id, version)) in map { self.held_status.insert( - vfid, + vfid.clone(), match member_id { Some(member_id) => HeldStatus::HeldWith(member_id), None => HeldStatus::NotHeld, }, ); + self.versions.insert(vfid, version); } } } |
