mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
fix: improve /drop handling of relative paths with samefile check
This commit is contained in:
parent
91613fcbf7
commit
e2ebde75be
1 changed files with 15 additions and 2 deletions
|
@ -808,8 +808,21 @@ class Commands:
|
||||||
# Expand tilde in the path
|
# Expand tilde in the path
|
||||||
expanded_word = os.path.expanduser(word)
|
expanded_word = os.path.expanduser(word)
|
||||||
|
|
||||||
# Handle read-only files with substring matching
|
# Handle read-only files with substring matching and samefile check
|
||||||
read_only_matched = [f for f in self.coder.abs_read_only_fnames if expanded_word in f]
|
read_only_matched = []
|
||||||
|
for f in self.coder.abs_read_only_fnames:
|
||||||
|
if expanded_word in f:
|
||||||
|
read_only_matched.append(f)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Try samefile comparison for relative paths
|
||||||
|
try:
|
||||||
|
abs_word = os.path.abspath(expanded_word)
|
||||||
|
if os.path.samefile(abs_word, f):
|
||||||
|
read_only_matched.append(f)
|
||||||
|
except (FileNotFoundError, OSError):
|
||||||
|
continue
|
||||||
|
|
||||||
for matched_file in read_only_matched:
|
for matched_file in read_only_matched:
|
||||||
self.coder.abs_read_only_fnames.remove(matched_file)
|
self.coder.abs_read_only_fnames.remove(matched_file)
|
||||||
self.io.tool_output(f"Removed read-only file {matched_file} from the chat")
|
self.io.tool_output(f"Removed read-only file {matched_file} from the chat")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue