Skip to content

Commit 2313600

Browse files
author
Will
committed
adapter/darwin: apple really likes duplicating events, fix the seen created path set removal logic in the create+rename case
1 parent c28e907 commit 2313600

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.14.4
4+
5+
- Fixed a rare misreporting error in the darwin/fsevents adapter where a rename event very quickly after a creation event on the same path could cause the creation event to be duplicated alongside the rename event.
6+
37
## 0.14.3
48

59
- Fixed duplicate creation events being reported on Linux in the inotify adapter when the event matched both the special directory creation path and the non-pending parse result path.

devel/include/detail/wtr/watcher/adapter/darwin/watch.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,21 @@ inline auto event_recv_one(ContextData& ctx, char const* path, unsigned flags)
135135
rename events, see this directory's
136136
notes (in the `notes.md` file).
137137
*/
138-
auto at = ctx.seen_created_paths->find(path);
139-
if (at != ctx.seen_created_paths->end())
140-
ctx.seen_created_paths->erase(at);
141138
auto lr_path = *ctx.last_rename_path;
142139
auto differs = ! lr_path.empty() && lr_path != path;
143140
auto missing = access(lr_path.c_str(), F_OK) == -1;
144-
if (differs && missing)
141+
if (differs && missing) {
145142
ctx.callback({
146143
{lr_path, ety::rename, pt},
147144
{ path, ety::rename, pt}
148-
}),
149-
ctx.last_rename_path->clear();
150-
else
145+
});
146+
ctx.last_rename_path->clear();
147+
} else {
151148
*ctx.last_rename_path = path;
149+
auto at = ctx.seen_created_paths->find(path);
150+
if (at != ctx.seen_created_paths->end())
151+
ctx.seen_created_paths->erase(at);
152+
}
152153
}
153154
}
154155

include/wtr/watcher.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -615,20 +615,21 @@ inline auto event_recv_one(ContextData& ctx, char const* path, unsigned flags)
615615
rename events, see this directory's
616616
notes (in the `notes.md` file).
617617
*/
618-
auto at = ctx.seen_created_paths->find(path);
619-
if (at != ctx.seen_created_paths->end())
620-
ctx.seen_created_paths->erase(at);
621618
auto lr_path = *ctx.last_rename_path;
622619
auto differs = ! lr_path.empty() && lr_path != path;
623620
auto missing = access(lr_path.c_str(), F_OK) == -1;
624-
if (differs && missing)
621+
if (differs && missing) {
625622
ctx.callback({
626623
{lr_path, ety::rename, pt},
627624
{ path, ety::rename, pt}
628-
}),
629-
ctx.last_rename_path->clear();
630-
else
625+
});
626+
ctx.last_rename_path->clear();
627+
} else {
631628
*ctx.last_rename_path = path;
629+
auto at = ctx.seen_created_paths->find(path);
630+
if (at != ctx.seen_created_paths->end())
631+
ctx.seen_created_paths->erase(at);
632+
}
632633
}
633634
}
634635

0 commit comments

Comments
 (0)