fix: support 4-part Windows version in version comparison

This commit is contained in:
SashegDev
2026-07-30 11:12:08 +00:00
parent 424cf9bc25
commit 15532bf341
5 changed files with 277 additions and 15 deletions
+32
View File
@@ -33,6 +33,7 @@ from playtime import router as playtime_router, init_playtime_db
import asyncio
import hashlib
import uuid
import aiofiles
import mimetypes
@@ -67,6 +68,9 @@ MANUAL_BLOCKED_IPS = set(os.environ.get("BLOCKED_IPS", "").split(",")) - {""} #
# Cache file for blocklist (load once)
BLOCKLIST_CACHE_FILE = Path("data/blocklist_cache.txt")
# Crash reports directory
CRASH_REPORTS_DIR = Path("data/crash_reports")
@asynccontextmanager
async def lifespan(app: FastAPI):
@@ -143,6 +147,7 @@ async def lifespan(app: FastAPI):
BUILDS_DIR.mkdir(exist_ok=True)
PACKS_DIR.mkdir(exist_ok=True)
DATA_DIR.mkdir(exist_ok=True)
CRASH_REPORTS_DIR.mkdir(exist_ok=True)
init_db()
init_friends_db()
@@ -1894,6 +1899,33 @@ async def get_launcher_full_info():
return info
@app.post("/launcher/crash-report")
async def receive_crash_report(request: Request):
"""Receive and store launcher crash reports"""
try:
body = await request.json()
except Exception:
raise HTTPException(status_code=400, detail="Invalid JSON")
ip = request.client.host if request.client else "unknown"
body["source_ip"] = ip
body["received_at"] = datetime.utcnow().isoformat()
report_id = datetime.utcnow().strftime("%Y%m%d_%H%M%S") + "_" + uuid.uuid4().hex[:8]
report_path = CRASH_REPORTS_DIR / f"{report_id}.json"
try:
CRASH_REPORTS_DIR.mkdir(parents=True, exist_ok=True)
async with aiofiles.open(report_path, "w", encoding="utf-8") as f:
await f.write(json.dumps(body, indent=2, ensure_ascii=False))
logger.info(f"Crash report saved: {report_path.name} from {ip}")
except Exception as e:
logger.error(f"Failed to save crash report: {e}")
raise HTTPException(status_code=500, detail="Failed to save report")
return {"status": "ok", "id": report_id}
# ====================== НОВОСТИ ======================
NEWS_DIR = Path(__file__).parent / "news"