mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
refactor: improve error handling for SQLite operations in RepoMap
This commit is contained in:
parent
1a6284cb24
commit
d82d21b8c1
1 changed files with 10 additions and 3 deletions
|
@ -27,6 +27,9 @@ from tree_sitter_languages import get_language, get_parser # noqa: E402
|
||||||
Tag = namedtuple("Tag", "rel_fname fname line name kind".split())
|
Tag = namedtuple("Tag", "rel_fname fname line name kind".split())
|
||||||
|
|
||||||
|
|
||||||
|
SQLITE_ERRORS = (sqlite3.OperationalError, sqlite3.DatabaseError)
|
||||||
|
|
||||||
|
|
||||||
class RepoMap:
|
class RepoMap:
|
||||||
CACHE_VERSION = 3
|
CACHE_VERSION = 3
|
||||||
TAGS_CACHE_DIR = f".aider.tags.cache.v{CACHE_VERSION}"
|
TAGS_CACHE_DIR = f".aider.tags.cache.v{CACHE_VERSION}"
|
||||||
|
@ -167,7 +170,7 @@ class RepoMap:
|
||||||
path = Path(self.root) / self.TAGS_CACHE_DIR
|
path = Path(self.root) / self.TAGS_CACHE_DIR
|
||||||
try:
|
try:
|
||||||
self.TAGS_CACHE = Cache(path)
|
self.TAGS_CACHE = Cache(path)
|
||||||
except sqlite3.OperationalError:
|
except SQLITE_ERRORS:
|
||||||
self.io.tool_warning(f"Unable to use tags cache, delete {path} to resolve.")
|
self.io.tool_warning(f"Unable to use tags cache, delete {path} to resolve.")
|
||||||
self.TAGS_CACHE = dict()
|
self.TAGS_CACHE = dict()
|
||||||
|
|
||||||
|
@ -195,8 +198,12 @@ class RepoMap:
|
||||||
data = list(self.get_tags_raw(fname, rel_fname))
|
data = list(self.get_tags_raw(fname, rel_fname))
|
||||||
|
|
||||||
# Update the cache
|
# Update the cache
|
||||||
self.TAGS_CACHE[cache_key] = {"mtime": file_mtime, "data": data}
|
try:
|
||||||
self.save_tags_cache()
|
self.TAGS_CACHE[cache_key] = {"mtime": file_mtime, "data": data}
|
||||||
|
self.save_tags_cache()
|
||||||
|
except SQLITE_ERRORS:
|
||||||
|
pass
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_tags_raw(self, fname, rel_fname):
|
def get_tags_raw(self, fname, rel_fname):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue