From 240da2de7a9951c67bec0be9a3c4708f545ae210 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 15 Dec 2025 10:53:25 +0800 Subject: Prevent lost file classification for erased directories The lost files calculation now filters out paths that are already marked as erased, avoiding duplicate classification. --- .../vcs_data/src/data/local/workspace_analyzer.rs | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'crates/vcs_data/src/data/local/workspace_analyzer.rs') diff --git a/crates/vcs_data/src/data/local/workspace_analyzer.rs b/crates/vcs_data/src/data/local/workspace_analyzer.rs index 599e4a3..a17063c 100644 --- a/crates/vcs_data/src/data/local/workspace_analyzer.rs +++ b/crates/vcs_data/src/data/local/workspace_analyzer.rs @@ -145,18 +145,6 @@ impl<'a> AnalyzeResult<'a> { }; let file_relative_paths_ref: HashSet<&PathBuf> = file_relative_paths.iter().collect(); - // Files that exist in the local sheet but not in reality are considered lost - let mut lost_files: HashSet<&PathBuf> = local_sheet_paths - .difference(&file_relative_paths_ref) - .cloned() - .collect(); - - // Files that exist in reality but not in the local sheet are recorded as newly created - let mut new_files: HashSet<&PathBuf> = file_relative_paths_ref - .difference(&local_sheet_paths) - .cloned() - .collect(); - // Files that exist locally but not in remote let mut erased_files: HashSet = HashSet::new(); @@ -174,6 +162,19 @@ impl<'a> AnalyzeResult<'a> { } } + // Files that exist in the local sheet but not in reality are considered lost + let mut lost_files: HashSet<&PathBuf> = local_sheet_paths + .difference(&file_relative_paths_ref) + .filter(|&&path| !erased_files.contains(path)) + .cloned() + .collect(); + + // Files that exist in reality but not in the local sheet are recorded as newly created + let mut new_files: HashSet<&PathBuf> = file_relative_paths_ref + .difference(&local_sheet_paths) + .cloned() + .collect(); + // Calculate hashes for new files let new_files_for_hash: Vec = new_files .iter() -- cgit