fix(kqueue): replace .renamed events with .deleted as they are now equivalent

This commit is contained in:
CJ van den Berg 2026-03-30 21:55:35 +02:00
parent 7171ad1905
commit b99d0e57a6
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 4 additions and 4 deletions

View file

@ -175,7 +175,7 @@ fn thread_fn(self: *@This(), allocator: std.mem.Allocator) void {
// skipped by scan_dir's snapshots.contains() check.
self.remove_watch(allocator, dir_path);
} else if (ev.fflags & NOTE_RENAME != 0) {
self.handler.change(dir_path, EventType.renamed, .dir) catch |e| {
self.handler.change(dir_path, EventType.deleted, .dir) catch |e| {
std.log.err("nightwatch: handler returned {s}, stopping watch thread", .{@errorName(e)});
return;
};

View file

@ -136,7 +136,7 @@ fn thread_fn(self: *@This(), allocator: std.mem.Allocator) void {
return;
};
} else if (ev.fflags & NOTE_RENAME != 0) {
self.handler.change(watch_path, EventType.renamed, .file) catch |e| {
self.handler.change(watch_path, EventType.deleted, .file) catch |e| {
std.log.err("nightwatch: handler returned {s}, stopping watch thread", .{@errorName(e)});
return;
};
@ -156,7 +156,7 @@ fn thread_fn(self: *@This(), allocator: std.mem.Allocator) void {
// skipped by scan_dir's snapshots.contains() check.
self.remove_watch(allocator, watch_path);
} else if (ev.fflags & NOTE_RENAME != 0) {
self.handler.change(watch_path, EventType.renamed, .dir) catch |e| {
self.handler.change(watch_path, EventType.deleted, .dir) catch |e| {
std.log.err("nightwatch: handler returned {s}, stopping watch thread", .{@errorName(e)});
return;
};

View file

@ -33,7 +33,7 @@ pub const EventType = enum {
/// destination side.
///
/// - **kqueue / kqueuedir**: when a watched *directory* is itself
/// renamed, a `renamed` change event is emitted for the old directory
/// renamed, a `deleted` change event is emitted for the old directory
/// path (the new path is not known). Renames of *files inside* a
/// watched directory are detected indirectly via directory-level
/// `NOTE_WRITE` events and appear as `deleted` + `created`.