mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-27 20:40:13 +03:00
Fix silent file write failure in write_compute_project_file
The inner try-except caught OSError/UnicodeEncodeError with 'pass', silently swallowing all write failures and returning HTTP 204 as if the file was written successfully. Remove the nested try-except and let errors propagate properly: - OSError → 500 with error detail - PermissionError → 403 (already handled) - FileNotFoundError → 404 (already handled)
This commit is contained in:
parent
cbb21e8e40
commit
16a9064eb8
@ -194,17 +194,17 @@ async def write_compute_project_file(
|
||||
try:
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
|
||||
try:
|
||||
with open(path, "wb+") as f:
|
||||
async for chunk in request.stream():
|
||||
f.write(chunk)
|
||||
except (UnicodeEncodeError, OSError) as e:
|
||||
pass # FIXME
|
||||
with open(path, "wb+") as f:
|
||||
async for chunk in request.stream():
|
||||
f.write(chunk)
|
||||
|
||||
except FileNotFoundError:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
||||
except PermissionError:
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN)
|
||||
except OSError as e:
|
||||
log.error(f"Error writing file '{path}': {e}")
|
||||
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e))
|
||||
|
||||
|
||||
@router.delete("/projects/{project_id}/files/{file_path:path}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user