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):
|
def main(report_error, report_action=prints):
|
||||||
try:
|
try:
|
||||||
|
if time.time() - cache.mtime() < UPDATE_INTERVAL:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
report_action('Fetching metadata source hashes...')
|
report_action('Fetching metadata source hashes...')
|
||||||
needed = update_needed()
|
needed = update_needed()
|
||||||
@ -78,9 +80,6 @@ def main(report_error, report_action=prints):
|
|||||||
def update_sources(wait_for_completion=False):
|
def update_sources(wait_for_completion=False):
|
||||||
if update_sources.worker is not None:
|
if update_sources.worker is not None:
|
||||||
return False
|
return False
|
||||||
epoch = cache.get('last_update', 0)
|
|
||||||
if time.time() - epoch < UPDATE_INTERVAL:
|
|
||||||
return False
|
|
||||||
update_sources.errors = errs = []
|
update_sources.errors = errs = []
|
||||||
update_sources.worker = t = Thread(
|
update_sources.worker = t = Thread(
|
||||||
target=main, args=(errs.append, debug_print), name='MSourcesUpdater')
|
target=main, args=(errs.append, debug_print), name='MSourcesUpdater')
|
||||||
|
@ -286,6 +286,12 @@ class XMLConfig(dict):
|
|||||||
|
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
|
def mtime(self):
|
||||||
|
try:
|
||||||
|
return os.path.getmtime(self.file_path)
|
||||||
|
except EnvironmentError:
|
||||||
|
return 0
|
||||||
|
|
||||||
def raw_to_object(self, raw):
|
def raw_to_object(self, raw):
|
||||||
return plistlib.readPlistFromString(raw)
|
return plistlib.readPlistFromString(raw)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user