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

Method save_file_hash

rust-core/src/storage/persistence.rs:140–157  ·  view source on GitHub ↗
(&self, project_id: &str, file_path: &str, hash: &str)

Source from the content-addressed store, hash-verified

138 }
139
140 pub fn save_file_hash(&self, project_id: &str, file_path: &str, hash: &str) -> io::Result<()> {
141 let project_dir = self.project_dir(project_id);
142 fs::create_dir_all(&project_dir)?;
143
144 let hash_file = project_dir.join("file_hashes.json");
145 let mut hashes: HashMap<String, String> = if hash_file.exists() {
146 let content = fs::read_to_string(&hash_file)?;
147 serde_json::from_str(&content).unwrap_or_default()
148 } else {
149 HashMap::new()
150 };
151
152 hashes.insert(file_path.to_string(), hash.to_string());
153 let json = serde_json::to_string_pretty(&hashes)?;
154 fs::write(hash_file, json)?;
155
156 Ok(())
157 }
158
159 pub fn load_file_hashes(&self, project_id: &str) -> io::Result<HashMap<String, String>> {
160 let hash_file = self.project_dir(project_id).join("file_hashes.json");

Callers 1

_save_file_hashesMethod · 0.80

Calls 3

project_dirMethod · 0.80
insertMethod · 0.80
to_stringMethod · 0.80

Tested by

no test coverage detected