mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement update interval for downloading metadata source plugins
This commit is contained in:
parent
e0f1fa9206
commit
889ec6e491
@ -57,6 +57,8 @@ def update_plugin(name):
|
||||
|
||||
def main(report_error, report_action=prints):
|
||||
try:
|
||||
if time.time() - cache.mtime() < UPDATE_INTERVAL:
|
||||
return
|
||||
try:
|
||||
report_action('Fetching metadata source hashes...')
|
||||
needed = update_needed()
|
||||
@ -78,9 +80,6 @@ def main(report_error, report_action=prints):
|
||||
def update_sources(wait_for_completion=False):
|
||||
if update_sources.worker is not None:
|
||||
return False
|
||||
epoch = cache.get('last_update', 0)
|
||||
if time.time() - epoch < UPDATE_INTERVAL:
|
||||
return False
|
||||
update_sources.errors = errs = []
|
||||
update_sources.worker = t = Thread(
|
||||
target=main, args=(errs.append, debug_print), name='MSourcesUpdater')
|
||||
|
@ -286,6 +286,12 @@ class XMLConfig(dict):
|
||||
|
||||
self.refresh()
|
||||
|
||||
def mtime(self):
|
||||
try:
|
||||
return os.path.getmtime(self.file_path)
|
||||
except EnvironmentError:
|
||||
return 0
|
||||
|
||||
def raw_to_object(self, raw):
|
||||
return plistlib.readPlistFromString(raw)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user