Skip to content

Commit

Permalink
Refactor Manual Runs (#75)
Browse files Browse the repository at this point in the history
* only create monitor when service is running

* simplify manual run

* beta version
  • Loading branch information
robweber committed Oct 20, 2023
1 parent b4310b8 commit 1c8b1d7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.libraryautoupdate"
name="Library Auto Update" version="1.2.5" provider-name="robweber">
name="Library Auto Update" version="1.2.6~beta1" provider-name="robweber">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.dateutil" version="2.7.3" />
Expand Down
8 changes: 0 additions & 8 deletions manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions resources/lib/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1c8b1d7

Please sign in to comment.