mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-26 14:34:59 +00:00
fix: Create parent directories for history files and improve error handling
This commit is contained in:
parent
5b317e5ec0
commit
14af218ea2
1 changed files with 14 additions and 4 deletions
18
aider/io.py
18
aider/io.py
|
@ -308,6 +308,12 @@ class InputOutput:
|
|||
self.yes = yes
|
||||
|
||||
self.input_history_file = input_history_file
|
||||
if self.input_history_file:
|
||||
try:
|
||||
Path(self.input_history_file).parent.mkdir(parents=True, exist_ok=True)
|
||||
except (PermissionError, OSError) as e:
|
||||
self.tool_warning(f"Could not create directory for input history: {e}")
|
||||
self.input_history_file = None
|
||||
self.llm_history_file = llm_history_file
|
||||
if chat_history_file is not None:
|
||||
self.chat_history_file = Path(chat_history_file)
|
||||
|
@ -731,7 +737,6 @@ class InputOutput:
|
|||
if not self.input_history_file:
|
||||
return
|
||||
try:
|
||||
Path(self.input_history_file).parent.mkdir(parents=True, exist_ok=True)
|
||||
FileHistory(self.input_history_file).append_string(inp)
|
||||
# Also add to the in-memory history if it exists
|
||||
if self.prompt_session and self.prompt_session.history:
|
||||
|
@ -750,9 +755,14 @@ class InputOutput:
|
|||
if not self.llm_history_file:
|
||||
return
|
||||
timestamp = datetime.now().isoformat(timespec="seconds")
|
||||
with open(self.llm_history_file, "a", encoding="utf-8") as log_file:
|
||||
log_file.write(f"{role.upper()} {timestamp}\n")
|
||||
log_file.write(content + "\n")
|
||||
try:
|
||||
Path(self.llm_history_file).parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(self.llm_history_file, "a", encoding="utf-8") as log_file:
|
||||
log_file.write(f"{role.upper()} {timestamp}\n")
|
||||
log_file.write(content + "\n")
|
||||
except (PermissionError, OSError) as err:
|
||||
self.tool_warning(f"Unable to write to llm history file {self.llm_history_file}: {err}")
|
||||
self.llm_history_file = None
|
||||
|
||||
def display_user_input(self, inp):
|
||||
if self.pretty and self.user_input_color:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue