Harden image fetch algorithm
Prepare for database integration
This commit is contained in:
11
modules/shared/format_bytes.py
Normal file
11
modules/shared/format_bytes.py
Normal file
@@ -0,0 +1,11 @@
|
||||
def format_bytes(bytes_size):
|
||||
"""Convert bytes to human readable format"""
|
||||
if bytes_size < 1024:
|
||||
return f"{bytes_size} B"
|
||||
|
||||
for unit in ['B', 'KB', 'MB', 'GB', 'TB']:
|
||||
if bytes_size < 1024.0:
|
||||
return f"{bytes_size:.1f} {unit}"
|
||||
bytes_size /= 1024.0
|
||||
|
||||
return f"{bytes_size:.1f} PB"
|
||||
Reference in New Issue
Block a user