Browse Source

Limit auto update check

pull/6148/head
Ruud 9 years ago
parent
commit
39f5794f2b
  1. 18
      couchpotato/core/_base/updater/main.py

18
couchpotato/core/_base/updater/main.py

@ -12,7 +12,7 @@ import re
from couchpotato.api import addApiView from couchpotato.api import addApiView
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync from couchpotato.core.event import addEvent, fireEvent, fireEventAsync
from couchpotato.core.helpers.encoding import sp from couchpotato.core.helpers.encoding import sp
from couchpotato.core.helpers.variable import removePyc from couchpotato.core.helpers.variable import removePyc, tryInt
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env from couchpotato.environment import Env
@ -29,6 +29,7 @@ class Updater(Plugin):
available_notified = False available_notified = False
_lock = RLock() _lock = RLock()
last_check = 'updater.last_check'
def __init__(self): def __init__(self):
@ -76,7 +77,20 @@ class Updater(Plugin):
self.autoUpdate() # Check after enabling self.autoUpdate() # Check after enabling
def autoUpdate(self): def autoUpdate(self):
if self.isEnabled() and self.check() and self.conf('automatic') and not self.updater.update_failed: do_check = True
try:
last_check = tryInt(Env.prop(self.last_check, default = 0))
now = tryInt(time.time())
do_check = last_check < now - 43200
if do_check:
Env.prop(self.last_check, value = now)
except:
log.error('Failed checking last time to update: %s', traceback.format_exc())
if do_check and self.isEnabled() and self.check() and self.conf('automatic') and not self.updater.update_failed:
if self.updater.doUpdate(): if self.updater.doUpdate():
# Notify before restarting # Notify before restarting

Loading…
Cancel
Save