🐛 修复下载历史重复计数

This commit is contained in:
2026-06-05 16:34:07 +08:00
parent 87d8f522a6
commit 85af153b38
3 changed files with 37 additions and 7 deletions
+6 -4
View File
@@ -292,8 +292,9 @@ async def select_file(data: SelectFileModel, ip: str = Depends(ip_limit["error"]
return APIResponse(code=404, detail=file_code)
assert isinstance(file_code, FileCodes)
await update_file_usage(file_code)
await record_transfer_stat("download", file_code, file_code.size, ip)
if file_code.text is not None:
await update_file_usage(file_code)
await record_transfer_stat("download", file_code, file_code.size, ip)
return APIResponse(detail=await build_select_detail(file_code, file_storage))
@@ -303,10 +304,11 @@ async def download_file(key: str, code: str, ip: str = Depends(ip_limit["error"]
if await get_select_token(code) != key:
ip_limit["error"].add_ip(ip)
raise HTTPException(status_code=403, detail="下载鉴权失败")
has, file_code = await get_code_file_by_code(code, False)
has, file_code = await get_code_file_by_code(code)
if not has:
return APIResponse(code=404, detail="文件不存在")
return APIResponse(code=404, detail=file_code)
assert isinstance(file_code, FileCodes)
await update_file_usage(file_code)
await record_transfer_stat("download", file_code, file_code.size, ip)
return (
APIResponse(detail=file_code.text)