| import os | |
| def safe_size(root): | |
| total = 0 | |
| for dirpath, dirnames, filenames in os.walk(root, followlinks=False): | |
| for f in filenames: | |
| try: | |
| path = os.path.join(dirpath, f) | |
| # skip broken symlinks just in case | |
| if os.path.islink(path): | |
| continue | |
| total += os.path.getsize(path) | |
| except OSError: | |
| continue | |
| return total | |
| paths = [ | |
| "/data/matches", | |
| "/data/by-language", | |
| "/data/image-shards" | |
| ] | |
| for p in paths: | |
| size = safe_size(p) | |
| print(f"{p}: {size / 1024**3:.2f} GB") |