From ef0fcb8f38cc37d2c636df92fa86493d4c914387 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 29 Oct 2024 15:04:00 -0700 Subject: [PATCH] refactor: Improve SQLite cache error handling and import organization --- aider/repomap.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aider/repomap.py b/aider/repomap.py index 5d35fdb78..ce749b014 100644 --- a/aider/repomap.py +++ b/aider/repomap.py @@ -2,6 +2,7 @@ import colorsys import math import os import random +import shutil import sqlite3 import sys import time @@ -168,7 +169,7 @@ class RepoMap: def tags_cache_error(self): """Handle SQLite errors by trying to recreate cache, falling back to dict if needed""" - if not isinstance(self.TAGS_CACHE, Cache): + if isinstance(getattr(self, "TAGS_CACHE", None), dict): return path = Path(self.root) / self.TAGS_CACHE_DIR @@ -177,8 +178,6 @@ class RepoMap: try: # Delete existing cache dir if path.exists(): - import shutil - shutil.rmtree(path) # Try to create new cache