File size: 624 Bytes
75880e1 6ea58c2 75880e1 6ea58c2 75880e1 6ea58c2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 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") |