mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 18:25:00 +00:00
refactor: simplify directory handling in FileWatcher class
This commit is contained in:
parent
496b92536f
commit
8cf72a4409
1 changed files with 4 additions and 6 deletions
|
@ -67,10 +67,8 @@ class FileWatcher:
|
|||
|
||||
def __init__(self, coder, encoding="utf-8", gitignores=None):
|
||||
self.coder = coder
|
||||
self.directory = coder.root
|
||||
self.encoding = encoding
|
||||
self.root = Path(self.directory)
|
||||
self.root_abs = self.root.absolute()
|
||||
self.root = Path(coder.root)
|
||||
self.stop_event = None
|
||||
self.watcher_thread = None
|
||||
self.changed_files = None
|
||||
|
@ -83,10 +81,10 @@ class FileWatcher:
|
|||
path_obj = Path(path)
|
||||
path_abs = path_obj.absolute()
|
||||
|
||||
if not path_abs.is_relative_to(self.root_abs):
|
||||
if not path_abs.is_relative_to(self.root.absolute()):
|
||||
return False
|
||||
|
||||
rel_path = path_abs.relative_to(self.root_abs)
|
||||
rel_path = path_abs.relative_to(self.root)
|
||||
if VERBOSE:
|
||||
dump(rel_path)
|
||||
|
||||
|
@ -128,7 +126,7 @@ class FileWatcher:
|
|||
def watch_files():
|
||||
try:
|
||||
for changes in watch(
|
||||
self.root, watch_filter=filter_func, stop_event=self.stop_event
|
||||
str(self.root), watch_filter=filter_func, stop_event=self.stop_event
|
||||
):
|
||||
changed_files = {str(Path(change[1])) for change in changes}
|
||||
result = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue