Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions livereload/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,16 @@ def is_file_changed(self, path, ignore=None):

def is_folder_changed(self, path, ignore=None):
"""Check if directory path has any changed filepaths."""
changed = False
for root, dirs, files in os.walk(path, followlinks=True):
for d in self.ignored_dirs:
if d in dirs:
dirs.remove(d)

for f in files:
if self.is_file_changed(os.path.join(root, f), ignore):
return True
return False
changed = True
return changed

def get_changed_glob_files(self, path, ignore=None):
"""Check if glob path has any changed filepaths."""
Expand Down
16 changes: 16 additions & 0 deletions tests/test_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ def test_watch_dir(self):
assert watcher.is_changed(tmpdir)
assert watcher.is_changed(tmpdir) is False

def test_watch_dir_reports_every_changed_file_at_once(self):
watcher = Watcher()
watcher._start -= 1

watcher.watch(tmpdir)
assert watcher.examine() == (None, None)

for name in ('foo', 'bar', 'baz'):
with open(os.path.join(tmpdir, name), 'w') as f:
f.write('')

reported, delay = watcher.examine()
assert reported is not None
assert delay is None
assert watcher.examine() == (None, None)

def test_watch_file(self):
watcher = Watcher()
watcher.count = 0
Expand Down