diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml
index 1ecd886..595d3be 100644
--- a/resources/language/English/strings.xml
+++ b/resources/language/English/strings.xml
@@ -100,4 +100,5 @@
is authorized
error authorizing
Visit https://console.developers.google.com/
+ Run on startup if missed
diff --git a/resources/settings.xml b/resources/settings.xml
index 69ffe7f..58c1ca7 100644
--- a/resources/settings.xml
+++ b/resources/settings.xml
@@ -36,6 +36,7 @@
-
+
+
diff --git a/scheduler.py b/scheduler.py
index 0b520e6..b01b507 100644
--- a/scheduler.py
+++ b/scheduler.py
@@ -12,13 +12,38 @@ class BackupScheduler:
monitor = None
enabled = "false"
next_run = 0
+ next_run_path = None
restore_point = None
def __init__(self):
self.monitor = UpdateMonitor(update_method = self.settingsChanged)
self.enabled = utils.getSetting("enable_scheduler")
+ self.next_run_path = xbmc.translatePath(utils.data_dir()) + 'next_run.txt'
if(self.enabled == "true"):
+
+ if(xbmcvfs.exists(self.next_run_path)):
+
+ nr = 0
+ fh = xbmcvfs.File(self.next_run_path)
+ try:
+ #check if we saved a run time from the last run
+ nr = float(fh.read())
+ except ValueError:
+ nr = 0
+
+ fh.close()
+
+ #if we missed and the user wants to play catch-up
+ if(0 < nr <= time.time() and utils.getSetting('schedule_miss') == 'true'):
+ utils.log("scheduled backup was missed, doing it now...")
+ progress_mode = int(utils.getSetting('progress_mode'))
+
+ if(progress_mode == 0):
+ progress_mode = 1 # Kodi just started, don't block it with a foreground progress bar
+
+ self.doScheduledBackup(progress_mode)
+
self.setup()
def setup(self):
@@ -46,26 +71,8 @@ class BackupScheduler:
if(self.next_run <= now):
progress_mode = int(utils.getSetting('progress_mode'))
- if(progress_mode != 2):
- utils.showNotification(utils.getString(30053))
-
- backup = XbmcBackup()
+ self.doScheduledBackup(progress_mode)
- if(backup.remoteConfigured()):
-
- if(int(utils.getSetting('progress_mode')) in [0,1]):
- backup.run(XbmcBackup.Backup,True)
- else:
- backup.run(XbmcBackup.Backup,False)
-
- #check if this is a "one-off"
- if(int(utils.getSetting("schedule_interval")) == 0):
- #disable the scheduler after this run
- self.enabled = "false"
- utils.setSetting('enable_scheduler','false')
- else:
- utils.showNotification(utils.getString(30045))
-
#check if we should shut the computer down
if(utils.getSetting("cron_shutdown") == 'true'):
#wait 10 seconds to make sure all backup processes and files are completed
@@ -80,6 +87,27 @@ class BackupScheduler:
#delete monitor to free up memory
del self.monitor
+ def doScheduledBackup(self,progress_mode):
+ if(progress_mode != 2):
+ utils.showNotification(utils.getString(30053))
+
+ backup = XbmcBackup()
+
+ if(backup.remoteConfigured()):
+
+ if(int(utils.getSetting('progress_mode')) in [0,1]):
+ backup.run(XbmcBackup.Backup,True)
+ else:
+ backup.run(XbmcBackup.Backup,False)
+
+ #check if this is a "one-off"
+ if(int(utils.getSetting("schedule_interval")) == 0):
+ #disable the scheduler after this run
+ self.enabled = "false"
+ utils.setSetting('enable_scheduler','false')
+ else:
+ utils.showNotification(utils.getString(30045))
+
def findNextRun(self,now):
progress_mode = int(utils.getSetting('progress_mode'))
@@ -93,6 +121,11 @@ class BackupScheduler:
self.next_run = new_run_time
utils.log("scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M'))
+ #write the next time to a file
+ fh = xbmcvfs.File(self.next_run_path, 'w')
+ fh.write(str(self.next_run))
+ fh.close()
+
#only show when not in silent mode
if(progress_mode != 2):
utils.showNotification(utils.getString(30081) + " " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M'))