Function
_directory_size_bytes
(path: Path, max_files: int = 5000)
Source from the content-addressed store, hash-verified
| 424 | return str(resolved) |
| 425 | |
| 426 | |
| 427 | def _directory_size_bytes(path: Path, max_files: int = 5000) -> int: |
| 428 | if not path.exists() or not path.is_dir(): |
| 429 | return 0 |
| 430 | total = 0 |
| 431 | count = 0 |
| 432 | for item in path.rglob("*"): |
| 433 | if count >= max_files: |
| 434 | break |
| 435 | try: |
| 436 | if item.is_file(): |
| 437 | total += item.stat().st_size |
| 438 | count += 1 |
| 439 | except OSError: |
| 440 | continue |
| 441 | return total |
| 442 | |
| 443 | |
Tested by
no test coverage detected