From 1c8b1d780b66461409ca940019532767bc526775 Mon Sep 17 00:00:00 2001 From: Rob <1572423+robweber@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:44:46 -0500 Subject: [PATCH] Refactor Manual Runs (#75) * only create monitor when service is running * simplify manual run * beta version --- addon.xml | 2 +- manual.py | 8 -------- resources/lib/service.py | 4 ++-- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/addon.xml b/addon.xml index 5f62ae7..cd9e369 100644 --- a/addon.xml +++ b/addon.xml @@ -1,6 +1,6 @@  + name="Library Auto Update" version="1.2.6~beta1" provider-name="robweber"> diff --git a/manual.py b/manual.py index 46a1188..8300e26 100644 --- a/manual.py +++ b/manual.py @@ -17,13 +17,5 @@ # run the program utils.log("Update Library Manual Run...") - # trick the auto updater into resetting the last_run time - autoUpdate.last_run = 0 - autoUpdate.writeLastRun() - # update the schedules and evaluate them in manual override mode - autoUpdate.createSchedules(True) autoUpdate.evalSchedules(True) - - # delete the monitor before exiting - del autoUpdate.monitor diff --git a/resources/lib/service.py b/resources/lib/service.py index 0fd675f..3ced21c 100644 --- a/resources/lib/service.py +++ b/resources/lib/service.py @@ -20,13 +20,13 @@ class AutoUpdater: def __init__(self): utils.check_data_dir() # in case this directory does not exist yet - self.monitor = UpdateMonitor(update_settings=self.createSchedules, after_scan=self.databaseUpdated) self.readLastRun() # force and update on startup to create the array self.createSchedules(True) def runProgram(self): + self.monitor = UpdateMonitor(update_settings=self.createSchedules, after_scan=self.databaseUpdated) # a one-time catch for the startup delay if(utils.getSettingInt("startup_delay") != 0): count = 0 @@ -70,7 +70,7 @@ def evalSchedules(self, manual=False): while count < len(self.schedules): cronJob = self.schedules[count] - if(cronJob.next_run <= now): + if(cronJob.next_run <= now or manual): if(not player.isPlaying() or utils.getSetting("run_during_playback") == "true"): # check if run on idle is checked and screen is idle - disable this on manual run