From be1e45a4b3c87efad99008b85c021a9d8b6f176b Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 3 Sep 2024 07:55:48 -0700 Subject: [PATCH] refactor: simplify file existence check and error handling in RepoMap --- aider/repomap.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/aider/repomap.py b/aider/repomap.py index 16ad1a288..fdc6fb0e3 100644 --- a/aider/repomap.py +++ b/aider/repomap.py @@ -307,16 +307,15 @@ class RepoMap: if progress and not showing_bar: progress() - if not Path(fname).is_file(): - if fname not in self.warned_files: - if Path(fname).exists(): - self.io.tool_error( - f"Repo-map can't include {fname}, it is not a normal file" - ) - else: - self.io.tool_error(f"Repo-map can't include {fname}, it no longer exists") + try: + file_ok = Path(fname).is_file() + except OSError: + file_ok = False - self.warned_files.add(fname) + if not file_ok: + if fname not in self.warned_files: + self.io.tool_error(f"Repo-map can't include {fname}") + self.warned_files.add(fname) continue # dump(fname)