mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-12-01 00:38:13 +08:00
fix: cannot start when not ready
This commit is contained in:
@@ -45,8 +45,7 @@ async def start(current_user=Depends(get_current_user)):
|
||||
status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token"
|
||||
)
|
||||
try:
|
||||
program.start()
|
||||
return {"status": "ok"}
|
||||
return program.start()
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
logger.warning("Failed to start program")
|
||||
@@ -59,8 +58,7 @@ async def stop(current_user=Depends(get_current_user)):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token"
|
||||
)
|
||||
program.stop()
|
||||
return {"status": "ok"}
|
||||
return program.stop()
|
||||
|
||||
|
||||
@router.get("/api/v1/status", tags=["program"])
|
||||
|
||||
@@ -35,6 +35,8 @@ class Program(RenameThread, RSSThread):
|
||||
self.start()
|
||||
|
||||
def start(self):
|
||||
if self.first_run:
|
||||
return {"status": "Not ready to start."}
|
||||
self.stop_event.clear()
|
||||
settings.load()
|
||||
if self.enable_renamer:
|
||||
@@ -49,6 +51,7 @@ class Program(RenameThread, RSSThread):
|
||||
self.stop_event.set()
|
||||
self.rename_stop()
|
||||
self.rss_stop()
|
||||
return {"status": "Program stopped."}
|
||||
else:
|
||||
return {"status": "Program is not running."}
|
||||
|
||||
|
||||
@@ -16,7 +16,10 @@ class ProgramStatus(Checker):
|
||||
|
||||
@property
|
||||
def is_running(self):
|
||||
return not self.stop_event.is_set()
|
||||
if self.stop_event.is_set() or self.check_first_run():
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
@property
|
||||
def is_stopped(self):
|
||||
|
||||
Reference in New Issue
Block a user