Bootstrap: incremental update via meta, server: fix file endpoint paths

This commit is contained in:
SashegDev
2026-05-08 18:45:42 +00:00
parent 099df80cc6
commit 4697b16ab4
2 changed files with 159 additions and 22 deletions
+8 -2
View File
@@ -1216,14 +1216,20 @@ async def get_launcher_diff(request: Request):
@app.get("/launcher/file/{version}/{file_path:path}")
async def get_launcher_file(version: str, file_path: str, request: Request):
"""Download a specific file from a launcher version"""
full_path = VERSIONS_DIR / version / file_path
# Ищем в builds/ директории (где лежит zernmc.exe, lib, assets и т.д.)
full_path = BUILDS_DIR / file_path
# Security: prevent path traversal
if ".." in file_path:
raise HTTPException(403, "Invalid file path")
if not full_path.exists() or not full_path.is_file():
raise HTTPException(404, "File not found")
# Fallback: ищем в versions директории
alt_path = VERSIONS_DIR / version / file_path
if alt_path.exists() and alt_path.is_file():
full_path = alt_path
else:
raise HTTPException(404, "File not found: " + file_path)
return FileResponse(full_path, direct_passthrough=True)