diff --git a/src/watchdog/utils/dirsnapshot.py b/src/watchdog/utils/dirsnapshot.py index 20abe221d..ffb404732 100644 --- a/src/watchdog/utils/dirsnapshot.py +++ b/src/watchdog/utils/dirsnapshot.py @@ -82,7 +82,7 @@ def __init__(self, ref, snapshot): for path in set(deleted): inode = ref.inode(path) new_path = snapshot.path(inode) - if new_path: + if new_path and ref.mtime(path) == snapshot.mtime(new_path): # file is not deleted but moved deleted.remove(path) moved.add((path, new_path)) @@ -90,7 +90,7 @@ def __init__(self, ref, snapshot): for path in set(created): inode = snapshot.inode(path) old_path = ref.path(inode) - if old_path: + if old_path and ref.mtime(old_path) == snapshot.mtime(path): created.remove(path) moved.add((old_path, path)) diff --git a/tests/test_snapshot_diff.py b/tests/test_snapshot_diff.py index b29fcdab0..5a176ebf7 100644 --- a/tests/test_snapshot_diff.py +++ b/tests/test_snapshot_diff.py @@ -27,11 +27,7 @@ def wait(): Wait long enough for file/folder mtime to change. This is needed to be able to detected modifications. """ - if platform.is_darwin() or platform.is_windows(): - # on osx resolution of stat.mtime is only 1 second - time.sleep(1.5) - else: - time.sleep(0.5) + time.sleep(1.5) def test_move_to(p): @@ -104,5 +100,7 @@ def test_detect_modify_for_moved_files(p): touch(p('a')) mv(p('a'), p('b')) diff = DirectorySnapshotDiff(ref, DirectorySnapshot(p(''))) - assert diff.files_moved == [(p('a'), p('b'))] - assert diff.files_modified == [p('a')] + assert diff.files_moved == [] + assert diff.files_created == [p('b')] + assert diff.files_deleted == [p('a')] + assert diff.files_modified == []