(&self, project_id: &str, file_path: &str, hash: &str)
| 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"); |
no test coverage detected