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.added = datetime.datetime.utcnow()
automation.updated = automation.added automation.updated = automation.added
db.session.add(automation) db.session.add(automation)
db.session.commit()
else: else:
if automation.state == AutomationState.RUNNING and not force: if automation.state == AutomationState.RUNNING and not force:
logging.warning("Not running an already running automation") 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") logging.warning("Not time to run this job yet")
return return
if not automation.enabled and not force: if not automation.enabled and not force:
db.session.rollback()
logging.warning(f"job {job.short_name} is disabled and --force not specified") logging.warning(f"job {job.short_name} is disabled and --force not specified")
return return
automation.state = AutomationState.RUNNING automation.state = AutomationState.RUNNING