refactor: Lazy-load model cache to respect SSL verification settings

This commit is contained in:
Paul Gauthier (aider) 2025-03-05 18:37:40 -08:00
parent d3ad1fd384
commit 4bac8e2ebe

View file

@ -139,12 +139,15 @@ class ModelInfoManager:
self.content = None
self.local_model_metadata = {}
self.verify_ssl = True
self._load_cache()
self._cache_loaded = False
def set_verify_ssl(self, verify_ssl):
self.verify_ssl = verify_ssl
def _load_cache(self):
if self._cache_loaded:
return
try:
self.cache_dir.mkdir(parents=True, exist_ok=True)
if self.cache_file.exists():
@ -153,6 +156,8 @@ class ModelInfoManager:
self.content = json.loads(self.cache_file.read_text())
except OSError:
pass
self._cache_loaded = True
def _update_cache(self):
try:
@ -179,6 +184,9 @@ class ModelInfoManager:
if data:
return data
# Ensure cache is loaded before checking content
self._load_cache()
if not self.content:
self._update_cache()