Skip to content

Commit 1c5e4ca

Browse files
committed
fix(cache): handle FileNotFoundError for stale cache entries during initialisation
Signed-off-by: Pavan-Rana <psrbr157@gmail.com>
1 parent 6f58fe9 commit 1c5e4ca

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sqlmesh/utils/cache.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ def __init__(self, path: Path, prefix: t.Optional[str] = None):
6363
# the file.stat() call below will fail on windows if the :file name is longer than 260 chars
6464
file = fix_windows_path(file)
6565

66-
if not file.stem.startswith(self._cache_version) or file.stat().st_atime < threshold:
67-
file.unlink(missing_ok=True)
66+
try:
67+
stat_result = file.stat()
68+
if not file.stem.startswith(self._cache_version) or stat_result.st_atime < threshold:
69+
file.unlink(missing_ok=True)
70+
except FileNotFoundError:
71+
continue
6872

6973
def get_or_load(self, name: str, entry_id: str = "", *, loader: t.Callable[[], T]) -> T:
7074
"""Returns an existing cached entry or loads and caches a new one.

0 commit comments

Comments
 (0)