updater: implementazione iniziale ricerca periodica

This commit is contained in:
marco
2020-01-04 00:31:33 +01:00
parent d1b5b83464
commit 18ee76903e
4 changed files with 28 additions and 5 deletions

View File

@@ -46,7 +46,7 @@ def loadCommits(page=1):
return ret
def check_addon_init():
def check():
if not addon.getSetting('addon_update_enabled'):
return False
logger.info('Cerco aggiornamenti..')
@@ -166,6 +166,27 @@ def check_addon_init():
return updated
def timer():
import time
curTime = time.time()
file = "special://profile/addon_data/plugin.video.kod/updater_last_check.txt"
period = 10
checked = False
try:
with open(xbmc.translatePath(file), 'r') as fileC:
lastCheck = float(fileC.read())
if curTime - lastCheck > period:
check()
checked = True
except:
check()
checked = True
if checked:
with open(xbmc.translatePath(file), 'w') as fileC:
fileC.write(str(curTime))
def calcCurrHash():
treeHash = githash.tree_hash(addonDir).hexdigest()
logger.info('tree hash: ' + treeHash)