show a progress bar if there are on tags/idents caches

This commit is contained in:
Paul Gauthier 2023-08-03 12:07:53 -03:00
parent 9ef730fd97
commit 3ef16827fc

View file

@ -14,6 +14,7 @@ from diskcache import Cache
from pygments.lexers import guess_lexer_for_filename from pygments.lexers import guess_lexer_for_filename
from pygments.token import Token from pygments.token import Token
from pygments.util import ClassNotFound from pygments.util import ClassNotFound
from tqdm import tqdm
from aider import models from aider import models
@ -74,6 +75,8 @@ class RepoMap:
ctags_disabled_reason = "ctags not initialized" ctags_disabled_reason = "ctags not initialized"
cache_missing = False
def __init__( def __init__(
self, self,
map_tokens=1024, map_tokens=1024,
@ -232,13 +235,19 @@ class RepoMap:
return True return True
def load_tags_cache(self): def load_tags_cache(self):
self.TAGS_CACHE = Cache(Path(self.root) / self.TAGS_CACHE_DIR) path = Path(self.root) / self.TAGS_CACHE_DIR
if not path.exists():
self.cache_missing = True
self.TAGS_CACHE = Cache(path)
def save_tags_cache(self): def save_tags_cache(self):
pass pass
def load_ident_cache(self): def load_ident_cache(self):
self.IDENT_CACHE = Cache(Path(self.root) / self.IDENT_CACHE_DIR) path = Path(self.root) / self.IDENT_CACHE_DIR
if not path.exists():
self.cache_missing = True
self.IDENT_CACHE = Cache(path)
def save_ident_cache(self): def save_ident_cache(self):
pass pass
@ -291,7 +300,13 @@ class RepoMap:
fnames = set(chat_fnames).union(set(other_fnames)) fnames = set(chat_fnames).union(set(other_fnames))
chat_rel_fnames = set() chat_rel_fnames = set()
for fname in sorted(fnames): fnames = sorted(fnames)
if self.cache_missing:
fnames = tqdm(fnames)
self.cache_missing = False
for fname in fnames:
# dump(fname) # dump(fname)
rel_fname = os.path.relpath(fname, self.root) rel_fname = os.path.relpath(fname, self.root)