检查文件是否需要更新
(&self, file_path: &Path)
| 44 | |
| 45 | /// 检查文件是否需要更新 |
| 46 | pub fn needs_update(&self, file_path: &Path) -> Result<bool, io::Error> { |
| 47 | let current_md5 = self.compute_file_md5(file_path)?; |
| 48 | |
| 49 | if let Some(metadata) = self.file_metadata.get(file_path) { |
| 50 | Ok(metadata.md5 != current_md5) |
| 51 | } else { |
| 52 | // 新文件,需要更新 |
| 53 | Ok(true) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /// 获取文件元数据 |
| 58 | pub fn get_file_metadata(&self, file_path: &Path) -> Option<&FileMetadata> { |
no test coverage detected