diff --git a/src/watchdog/events.py b/src/watchdog/events.py old mode 100644 new mode 100755 index 7c1f07509..074452248 --- a/src/watchdog/events.py +++ b/src/watchdog/events.py @@ -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 @@ -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):