feat: пробный доступ — не больше двух файлов за раз, версия 2026-10-01e
Считаются файлы после последнего вопроса плюс идущие загрузки (tus и /api/upload), страница не даёт выбрать лишнее. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+17
-1
@@ -113,6 +113,21 @@ def register_tus(app, *, get_user, get_work_dir, is_allowed_file,
|
||||
total += int(m.get("length") or 0)
|
||||
return total
|
||||
|
||||
def _pending_count(user, tab):
|
||||
"""Сколько загрузок человека в диалог ещё идёт — для предела «файлов за раз»."""
|
||||
n = 0
|
||||
fresh = time.time() - _PENDING_IDLE
|
||||
for mp in staging.glob("*.json"):
|
||||
try:
|
||||
if _data(mp.stem).stat().st_mtime < fresh:
|
||||
continue
|
||||
m = json.loads(mp.read_text("utf-8"))
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
if m.get("owner") == user and m.get("tab_id") == tab:
|
||||
n += 1
|
||||
return n
|
||||
|
||||
async def options_collection(request: Request):
|
||||
return Response(status_code=204, headers=_headers({
|
||||
"Tus-Version": TUS_VERSION,
|
||||
@@ -141,7 +156,8 @@ def register_tus(app, *, get_user, get_work_dir, is_allowed_file,
|
||||
_name = Path(_m.get("filename", "")).name or "?"
|
||||
try:
|
||||
_tab = _safe_tab(_m.get("tab_id"))
|
||||
check_upload(user, _tab, _name, length, _pending_bytes(user, _tab))
|
||||
check_upload(user, _tab, _name, length, _pending_bytes(user, _tab),
|
||||
pending_files=_pending_count(user, _tab))
|
||||
except HTTPException as refusal:
|
||||
log_action(user, "tus_reject", "POST", "/api/tus",
|
||||
f"{_name}: {refusal.detail}", ip, refusal.status_code)
|
||||
|
||||
Reference in New Issue
Block a user