Reset picker status between selections and harden upload guards

This commit is contained in:
Repinoid
2026-10-24 08:31:19 +03:00
parent eb61a1b356
commit 3c0c3a2043
7 changed files with 48 additions and 10 deletions
+6
View File
@@ -63,6 +63,12 @@ def upload():
if not name:
had_unnamed = True
continue
# Ранняя проверка размера по Content-Length позволяет не читать в память
# тело файла, заведомо превышающего лимит. Проверка выполняется до f.read().
if f.content_length is not None and f.content_length > MAX_FILE_BYTES:
log.warning("upload: file exceeds %dMB, skipped sid=%s file=%r size=%d",
MAX_FILE_BYTES // (1024 * 1024), sid, name, f.content_length)
continue
data = f.read()
log.info("upload: sid=%s file=%r size=%d", sid, name, len(data))
if len(data) > MAX_FILE_BYTES: