Merge pull request #700 from dadav/fix/auto-update-lock

Add Lock
This commit is contained in:
evilsocket 2019-12-07 16:28:57 +02:00 committed by GitHub
commit ee6c06f306
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import platform
import shutil
import glob
import pkg_resources
from threading import Lock
import pwnagotchi
import pwnagotchi.plugins as plugins
@ -150,6 +151,7 @@ class AutoUpdate(plugins.Plugin):
def __init__(self):
self.ready = False
self.status = StatusFile('/root/.auto-update')
self.lock = Lock()
def on_loaded(self):
if 'interval' not in self.options or ('interval' in self.options and self.options['interval'] is None):
@ -159,6 +161,7 @@ class AutoUpdate(plugins.Plugin):
logging.info("[update] plugin loaded.")
def on_internet_available(self, agent):
with self.lock:
logging.debug("[update] internet connectivity is available (ready %s)" % self.ready)
if not self.ready: