mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 04:35:00 +00:00
fix: Refactor code to handle exceptions more gracefully
This commit is contained in:
parent
6ab1fdfe36
commit
3b9f561956
1 changed files with 25 additions and 31 deletions
|
@ -74,21 +74,15 @@ def get_index():
|
||||||
dname = Path.home() / ".aider" / "caches" / ("help." + __version__)
|
dname = Path.home() / ".aider" / "caches" / ("help." + __version__)
|
||||||
|
|
||||||
index = None
|
index = None
|
||||||
|
|
||||||
if dname.exists():
|
|
||||||
try:
|
try:
|
||||||
|
if dname.exists():
|
||||||
storage_context = StorageContext.from_defaults(
|
storage_context = StorageContext.from_defaults(
|
||||||
persist_dir=dname,
|
persist_dir=dname,
|
||||||
)
|
)
|
||||||
index = load_index_from_storage(storage_context)
|
index = load_index_from_storage(storage_context)
|
||||||
except (OSError, json.JSONDecodeError):
|
except (OSError, json.JSONDecodeError):
|
||||||
shutil.rmtree(dname)
|
shutil.rmtree(dname)
|
||||||
pass
|
|
||||||
storage_context = StorageContext.from_defaults(
|
|
||||||
persist_dir=dname,
|
|
||||||
)
|
|
||||||
index = load_index_from_storage(storage_context)
|
|
||||||
else:
|
|
||||||
if index is None:
|
if index is None:
|
||||||
parser = MarkdownNodeParser()
|
parser = MarkdownNodeParser()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue