Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

identify synthesized events #369

Closed
wants to merge 2 commits into from
Closed
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
16 changes: 14 additions & 2 deletions src/watchdog/events.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ class FileSystemEvent(object):
is_directory = False
"""True if event was emitted for a directory; False otherwise."""

is_synthetic = False
"""
True if event was synthesized; False otherwise.

These are move events that weren't actually broadcast by the OS, but
are presumed to have happened based on other, actual events.
"""

def __init__(self, src_path):
self._src_path = src_path

Expand Down Expand Up @@ -590,11 +598,15 @@ def generate_sub_moved_events(src_dir_path, dest_dir_path):
for directory in directories:
full_path = os.path.join(root, directory)
renamed_path = full_path.replace(dest_dir_path, src_dir_path) if src_dir_path else None
yield DirMovedEvent(renamed_path, full_path)
event = DirMovedEvent(renamed_path, full_path)
event.is_synthetic = True
yield event
for filename in filenames:
full_path = os.path.join(root, filename)
renamed_path = full_path.replace(dest_dir_path, src_dir_path) if src_dir_path else None
yield FileMovedEvent(renamed_path, full_path)
event = FileMovedEvent(renamed_path, full_path)
event.is_synthetic = True
yield event


def generate_sub_created_events(src_dir_path):
Expand Down