diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-12-11 08:32:21 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-12-11 08:32:21 +0800 |
| commit | 74ee31689a620c2220b50d7c13abf36f80666047 (patch) | |
| tree | e0ba4e0ec0c936958246cdc5b71156d2fc12b5bc /crates/vcs_data/src/data/local/file_status.rs | |
| parent | 4cacb598fe0a13b950bcb38fa4275f1777621b03 (diff) | |
Match moved files using latest hash instead of initial hash
Diffstat (limited to 'crates/vcs_data/src/data/local/file_status.rs')
| -rw-r--r-- | crates/vcs_data/src/data/local/file_status.rs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/crates/vcs_data/src/data/local/file_status.rs b/crates/vcs_data/src/data/local/file_status.rs index b8b5952..7841237 100644 --- a/crates/vcs_data/src/data/local/file_status.rs +++ b/crates/vcs_data/src/data/local/file_status.rs @@ -79,13 +79,14 @@ impl<'a> AnalyzeResult<'a> { } if entry.file_type().is_file() - && let Ok(relative_path) = entry.path().strip_prefix(local_path) { - let format = format_path(relative_path.to_path_buf()); - let Ok(format) = format else { - continue; - }; - paths.insert(format); - } + && let Ok(relative_path) = entry.path().strip_prefix(local_path) + { + let format = format_path(relative_path.to_path_buf()); + let Ok(format) = format else { + continue; + }; + paths.insert(format); + } } paths @@ -174,7 +175,16 @@ impl<'a> AnalyzeResult<'a> { .iter() .filter_map(|f| { local_sheet.mapping_data(f).ok().map(|mapping_data| { - (mapping_data.hash_when_updated.clone(), (*f).clone()) + ( + // Using the most recently recorded Hash can more accurately identify moved items, + // but if it doesn't exist, fall back to the initially recorded Hash + mapping_data + .last_modifiy_check_hash + .as_ref() + .cloned() + .unwrap_or(mapping_data.hash_when_updated.clone()), + (*f).clone(), + ) }) }) .collect(), @@ -270,6 +280,9 @@ impl<'a> AnalyzeResult<'a> { mapping_data.last_modifiy_check_time = modified_time; mapping_data.last_modifiy_check_result = false; } + + // Record latest hash + mapping_data.last_modifiy_check_hash = Some(hash_calc.hash) } // Persist the local sheet data |
