🐛 修复下载历史重复计数
This commit is contained in:
+6
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user