Reduce metadata source plugin updates interval

Also touch the cache file even when there are no changes to avoid
excessive queries.
This commit is contained in:
Kovid Goyal 2017-03-02 19:46:57 +05:30
parent b9eea6b91c
commit 959583bcc2
2 changed files with 8 additions and 1 deletions

View File

@ -20,7 +20,7 @@ from calibre.utils.https import get_https_resource_securely
cache = JSONConfig('metadata-sources-cache.json')
UPDATE_INTERVAL = 24 * 60 * 60
UPDATE_INTERVAL = 12 * 60 * 60
current_search_engines = builtin_search_engines
@ -113,6 +113,7 @@ def main(report_error=prints, report_action=prints):
'Failed to get metadata sources hashes with error: {}'.format(as_unicode(e)))
return
if not needed:
cache.touch()
return
updated = {}
for name, expected_hash in needed.iteritems():

View File

@ -292,6 +292,12 @@ class XMLConfig(dict):
except EnvironmentError:
return 0
def touch(self):
try:
os.utime(self.file_path, None)
except EnvironmentError:
pass
def raw_to_object(self, raw):
return plistlib.readPlistFromString(raw)