diff --git a/src/calibre/ebooks/metadata/sources/update.py b/src/calibre/ebooks/metadata/sources/update.py index 7ef06e6ecc..52355c52af 100644 --- a/src/calibre/ebooks/metadata/sources/update.py +++ b/src/calibre/ebooks/metadata/sources/update.py @@ -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') diff --git a/src/calibre/utils/config.py b/src/calibre/utils/config.py index 4463ec5f31..ce69cd56c8 100644 --- a/src/calibre/utils/config.py +++ b/src/calibre/utils/config.py @@ -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)