MCPcopy Create free account
hub / github.com/CodeBendKit/codeseek / _should_skip_file

Method _should_skip_file

rust-core/src/codegraph/parser.rs:977–1000  ·  view source on GitHub ↗

检查文件是否应该跳过(基于MD5哈希值)

(&self, file_path: &PathBuf, file_hashes: &mut HashMap<String, String>)

Source from the content-addressed store, hash-verified

975
976 /// 检查文件是否应该跳过(基于MD5哈希值)
977 fn _should_skip_file(&self, file_path: &PathBuf, file_hashes: &mut HashMap<String, String>) -> Result<bool, String> {
978 use std::fs;
979 use md5;
980
981 // 计算当前文件的MD5哈希值
982 let content = fs::read(file_path)
983 .map_err(|e| format!("Failed to read file {}: {}", file_path.display(), e))?;
984 let current_hash = format!("{:x}", md5::compute(&content));
985
986 // 获取相对文件路径(相对于当前工作目录)
987 let file_path_str = file_path.to_string_lossy().to_string();
988
989 // 检查是否存在相同的哈希值
990 if let Some(saved_hash) = file_hashes.get(&file_path_str) {
991 if saved_hash == &current_hash {
992 debug!("File {} unchanged (MD5: {}), skipping", file_path.display(), current_hash);
993 return Ok(true);
994 }
995 }
996
997 // 更新哈希值
998 file_hashes.insert(file_path_str, current_hash);
999 Ok(false)
1000 }
1001
1002 /// 合并新解析的函数到现有图中
1003 fn _merge_new_functions(&self, code_graph: &mut PetCodeGraph) {

Callers 2

build_code_graphMethod · 0.80

Calls 3

to_stringMethod · 0.80
getMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected