Compute MD5 hash of file content. Args: file_path: Path to file to hash Returns: MD5 hash as hexadecimal string Raises: IOError: If file cannot be read
(self, file_path: Path)
| 121 | json.dump(data, f, indent=2) |
| 122 | |
| 123 | def _compute_md5(self, file_path: Path) -> str: |
| 124 | """ |
| 125 | Compute MD5 hash of file content. |
| 126 | |
| 127 | Args: |
| 128 | file_path: Path to file to hash |
| 129 | |
| 130 | Returns: |
| 131 | MD5 hash as hexadecimal string |
| 132 | |
| 133 | Raises: |
| 134 | IOError: If file cannot be read |
| 135 | """ |
| 136 | try: |
| 137 | hasher = hashlib.md5() |
| 138 | with open(file_path, "rb") as f: |
| 139 | # Read in chunks to handle large files efficiently |
| 140 | for chunk in iter(lambda: f.read(8192), b""): |
| 141 | hasher.update(chunk) |
| 142 | return hasher.hexdigest() |
| 143 | except IOError as e: |
| 144 | raise IOError(f"Cannot read file {file_path}: {e}") from e |
| 145 | |
| 146 | def has_changed(self, src_path: Path, previous_modtime: float) -> bool: |
| 147 | """ |
no test coverage detected