mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-28 12:30:20 +08:00
feat: use pathlib to replace os.path for handling file path
This commit is contained in:
@@ -14,7 +14,7 @@ async def get_log(current_user=Depends(get_current_user)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token"
|
||||
)
|
||||
if os.path.isfile(LOG_PATH):
|
||||
if LOG_PATH.exists():
|
||||
with open(LOG_PATH, "rb") as f:
|
||||
return Response(f.read(), media_type="text/plain")
|
||||
else:
|
||||
@@ -27,9 +27,8 @@ async def clear_log(current_user=Depends(get_current_user)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token"
|
||||
)
|
||||
if os.path.isfile(LOG_PATH):
|
||||
with open(LOG_PATH, "w") as f:
|
||||
f.write("")
|
||||
if LOG_PATH.exists():
|
||||
LOG_PATH.write_text("")
|
||||
return {"status": "ok"}
|
||||
else:
|
||||
return Response("Log file not found", status_code=404)
|
||||
|
||||
Reference in New Issue
Block a user