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

Method refresh_file

rust-core/src/storage/incremental.rs:63–94  ·  view source on GitHub ↗

更新单个文件

(
        &mut self,
        file_path: &PathBuf,
        entity_graph: &mut EntityGraph,
        call_graph: &mut PetCodeGraph,
    )

Source from the content-addressed store, hash-verified

61
62 /// 更新单个文件
63 pub fn refresh_file(
64 &mut self,
65 file_path: &PathBuf,
66 entity_graph: &mut EntityGraph,
67 call_graph: &mut PetCodeGraph,
68 ) -> Result<(), String> {
69 info!("Refreshing file: {}", file_path.display());
70
71 // 检查文件是否存在
72 if !file_path.exists() {
73 // 文件被删除,清理相关索引
74 self._remove_file_entities(file_path, entity_graph, call_graph);
75 return Ok(());
76 }
77
78 // 计算当前MD5
79 let current_md5 = self.compute_file_md5(file_path)
80 .map_err(|e| format!("Failed to compute MD5 for {}: {}", file_path.display(), e))?;
81
82 // 检查是否需要更新
83 if let Some(metadata) = self.file_metadata.get(file_path) {
84 if metadata.md5 == current_md5 {
85 debug!("File {} unchanged, skipping", file_path.display());
86 return Ok(());
87 }
88 }
89
90 // 文件需要更新,执行增量更新
91 self._update_file(file_path, &current_md5, entity_graph, call_graph)?;
92
93 Ok(())
94 }
95
96 /// 更新文件元数据
97 fn _update_file(

Callers

nothing calls this directly

Calls 4

compute_file_md5Method · 0.80
getMethod · 0.80
_update_fileMethod · 0.80
_remove_file_entitiesMethod · 0.45

Tested by

no test coverage detected