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
4 changes: 2 additions & 2 deletions src/watchdog/utils/dirsnapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ 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))

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))

Expand Down
12 changes: 5 additions & 7 deletions tests/test_snapshot_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 == []