Handle OSError in brave adblock

(cherry picked from commit 09c848fe34bd61fca74c6191ff5e49dbbf9ae101)
This commit is contained in:
Florian Bruhin 2021-03-19 17:47:06 +01:00
parent 2859be73ce
commit 4e849d234d
1 changed files with 7 additions and 1 deletions

View File

@ -203,7 +203,13 @@ class BraveAdBlocker:
def read_cache(self) -> None:
"""Initialize the adblocking engine from cache file."""
if self._cache_path.is_file():
try:
cache_exists = self._cache_path.is_file()
except OSError:
logger.error("Failed to read adblock cache", exc_info=True)
return
if cache_exists:
logger.debug("Loading cached adblock data: %s", self._cache_path)
self._engine.deserialize_from_file(str(self._cache_path))
else: