Bootstrap: incremental update via meta, server: fix file endpoint paths
This commit is contained in:
+8
-2
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user