automate: don't run automation on first sight

This commit is contained in:
Iain Learmonth 2022-05-14 12:05:06 +01:00
parent e84e77bb28
commit 7624252476

View file

@ -68,6 +68,7 @@ def run_job(job: BaseAutomation, *, force: bool = False, ignore_schedule: bool =
automation.added = datetime.datetime.utcnow()
automation.updated = automation.added
db.session.add(automation)
db.session.commit()
else:
if automation.state == AutomationState.RUNNING and not force:
logging.warning("Not running an already running automation")
@ -77,7 +78,6 @@ def run_job(job: BaseAutomation, *, force: bool = False, ignore_schedule: bool =
logging.warning("Not time to run this job yet")
return
if not automation.enabled and not force:
db.session.rollback()
logging.warning(f"job {job.short_name} is disabled and --force not specified")
return
automation.state = AutomationState.RUNNING