fix(update): 204 响应不通过 HTTPException 抛出,避免 Content-Length 校验失败
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, status
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, Response, status
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@@ -44,11 +44,11 @@ async def check_update(
|
||||
latest: AppRelease | None = result.scalar_one_or_none()
|
||||
|
||||
if not latest:
|
||||
raise HTTPException(status_code=status.HTTP_204_NO_CONTENT)
|
||||
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
# 已是最新版本(或更高)
|
||||
if latest.version == version:
|
||||
raise HTTPException(status_code=status.HTTP_204_NO_CONTENT)
|
||||
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
# 查询对应平台的包
|
||||
result = await db.execute(
|
||||
@@ -62,7 +62,7 @@ async def check_update(
|
||||
|
||||
if not pkg:
|
||||
# 该平台无包,返回 204(避免报错阻断用户)
|
||||
raise HTTPException(status_code=status.HTTP_204_NO_CONTENT)
|
||||
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
# 构建 Tauri 格式的响应
|
||||
platform_key = f"{target}-{arch}"
|
||||
|
||||
Reference in New Issue
Block a user