fix: Handle non-existent files in apply_edits

This commit is contained in:
Paul Gauthier (aider) 2024-08-09 16:32:15 -03:00
parent 210d313d52
commit 25c36503ff

View file

@ -1658,4 +1658,14 @@ class Coder:
return []
def apply_edits(self, edits):
for edit in edits:
path, content = edit
full_path = self.abs_root_path(path)
if not os.path.exists(full_path):
self.io.tool_error(f"Error: File {path} does not exist. Skipping edits.")
continue
if not self.dry_run:
with open(full_path, 'w', encoding=self.io.encoding) as f:
f.write(content)
return