Update bytes to GB with bitshift (#6886)

This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-03-07 19:26:37 +01:00
1 parent acc58c1dcf
commit e6e36aac10
4 files changed
+11 -10

No files matched your search

+3 -2
View File
@@ -223,11 +223,12 @@ def emojis(str=''):
def file_size(path):
# Return file/dir size (MB)
mb = 1 << 20 # bytes to MiB (1024 ** 2)
path = Path(path)
if path.is_file():
return path.stat().st_size / 1E6
return path.stat().st_size / mb
elif path.is_dir():
return sum(f.stat().st_size for f in path.glob('**/*') if f.is_file()) / 1E6
return sum(f.stat().st_size for f in path.glob('**/*') if f.is_file()) / mb
else:
return 0.0