mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
feat: add error handling for SQLite tags cache operations
This commit is contained in:
parent
e9771588e4
commit
68916b1186
1 changed files with 21 additions and 5 deletions
|
@ -166,13 +166,19 @@ class RepoMap:
|
|||
# Just return the full fname.
|
||||
return fname
|
||||
|
||||
def tags_cache_error(self):
|
||||
"""Handle SQLite errors by falling back to dict-based cache"""
|
||||
if isinstance(self.TAGS_CACHE, Cache):
|
||||
path = Path(self.root) / self.TAGS_CACHE_DIR
|
||||
self.io.tool_warning(f"Unable to use tags cache, delete {path} to resolve.")
|
||||
self.TAGS_CACHE = dict()
|
||||
|
||||
def load_tags_cache(self):
|
||||
path = Path(self.root) / self.TAGS_CACHE_DIR
|
||||
try:
|
||||
self.TAGS_CACHE = Cache(path)
|
||||
except SQLITE_ERRORS:
|
||||
self.io.tool_warning(f"Unable to use tags cache, delete {path} to resolve.")
|
||||
self.TAGS_CACHE = dict()
|
||||
self.tags_cache_error()
|
||||
|
||||
def save_tags_cache(self):
|
||||
pass
|
||||
|
@ -190,8 +196,17 @@ class RepoMap:
|
|||
return []
|
||||
|
||||
cache_key = fname
|
||||
try:
|
||||
val = self.TAGS_CACHE.get(cache_key) # Issue #1308
|
||||
except SQLITE_ERRORS:
|
||||
self.tags_cache_error()
|
||||
val = self.TAGS_CACHE.get(cache_key)
|
||||
|
||||
if val is not None and val.get("mtime") == file_mtime:
|
||||
try:
|
||||
return self.TAGS_CACHE[cache_key]["data"]
|
||||
except SQLITE_ERRORS:
|
||||
self.tags_cache_error()
|
||||
return self.TAGS_CACHE[cache_key]["data"]
|
||||
|
||||
# miss!
|
||||
|
@ -202,7 +217,8 @@ class RepoMap:
|
|||
self.TAGS_CACHE[cache_key] = {"mtime": file_mtime, "data": data}
|
||||
self.save_tags_cache()
|
||||
except SQLITE_ERRORS:
|
||||
pass
|
||||
self.tags_cache_error()
|
||||
self.TAGS_CACHE[cache_key] = {"mtime": file_mtime, "data": data}
|
||||
|
||||
return data
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue