Implement reusable upload platform

This commit is contained in:
“Naeel”
2026-09-05 08:51:32 +03:00
parent 82d9ca9136
commit c0b87880ae
35 changed files with 734 additions and 9 deletions
+17
View File
@@ -0,0 +1,17 @@
"""Добавление файла в сессию."""
from . import state
def add_file(sid: str, filename: str, content: bytes) -> bool:
"""Добавить файл, если сессия существует и общий лимит не превышен."""
with state._lock:
session = state._sessions.get(sid)
if not session:
return False
total = sum(len(item_content) for _, item_content in session["files"])
if total + len(content) > state.MAX_SESSION_BYTES:
return False
session["files"].append((filename, content))
return True