The `inspect` plugin should not fail hard if the cache couldn't be loaded.

This can happen for many reasons - not only if the cache file is not
accessible, but also if the structure/signature of some pickled objects
has changed. In that case, we should invalidate the current cache and
re-initialize it instead of failing.
This commit is contained in:
Fabio Manganiello 2023-06-28 01:33:12 +02:00
parent c5059f6908
commit 5e5403287e
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
1 changed files with 6 additions and 2 deletions

View File

@ -57,8 +57,12 @@ class InspectPlugin(Plugin):
try:
with open(self._components_cache_file, 'rb') as f:
self._components_cache = pickle.load(f)
except OSError:
return
except Exception as e:
self.logger.warning('Could not initialize the components cache: %s', e)
self.logger.info(
'The plugin will initialize the cache by scanning '
'the integrations at the next run. This may take a while'
)
def _flush_components_cache(self):
"""