Check if sufficient disk space is available. Args: path: Path to check disk space for required_mb: Required space in MB (default: 1GB) Returns: (has_space, error_message)
(path: Path, required_mb: int = 1000)
| 241 | |
| 242 | |
| 243 | def check_disk_space(path: Path, required_mb: int = 1000) -> tuple[bool, str]: |
| 244 | """Check if sufficient disk space is available. |
| 245 | |
| 246 | Args: |
| 247 | path: Path to check disk space for |
| 248 | required_mb: Required space in MB (default: 1GB) |
| 249 | |
| 250 | Returns: |
| 251 | (has_space, error_message) |
| 252 | """ |
| 253 | try: |
| 254 | stat = shutil.disk_usage(path) |
| 255 | available_mb = stat.free / (1024 * 1024) |
| 256 | |
| 257 | if available_mb < required_mb: |
| 258 | return ( |
| 259 | False, |
| 260 | f"Insufficient disk space: {available_mb:.1f}MB available, {required_mb}MB required", |
| 261 | ) |
| 262 | |
| 263 | return True, "" |
| 264 | except KeyboardInterrupt as ki: |
| 265 | handle_keyboard_interrupt(ki) |
| 266 | raise |
| 267 | except Exception as e: |
| 268 | return False, f"Failed to check disk space: {e}" |
| 269 | |
| 270 | |
| 271 | def is_network_error(error_output: str) -> bool: |
no test coverage detected