fix: Handle JSONDecodeError when loading model cache file

This commit is contained in:
Paul Gauthier (aider) 2025-03-11 08:33:18 -07:00
parent 38fd715247
commit 93c284a67d

View file

@ -153,7 +153,11 @@ class ModelInfoManager:
if self.cache_file.exists():
cache_age = time.time() - self.cache_file.stat().st_mtime
if cache_age < self.CACHE_TTL:
self.content = json.loads(self.cache_file.read_text())
try:
self.content = json.loads(self.cache_file.read_text())
except json.JSONDecodeError:
# If the cache file is corrupted, treat it as missing
self.content = None
except OSError:
pass