Harden image fetch algorithm

Prepare for database integration
This commit is contained in:
2025-09-24 20:07:19 +07:00
parent 88d40c0d99
commit 3a88bdad3a
17 changed files with 600 additions and 26 deletions

View 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"