fix: minor clean-up
This commit is contained in:
parent
4339c122eb
commit
bafa7d4b24
3 changed files with 9 additions and 3 deletions
|
|
@ -16,7 +16,7 @@ watches_mutex: std.Thread.Mutex,
|
|||
file_watches: std.StringHashMapUnmanaged(std.posix.fd_t), // owned file path -> fd
|
||||
file_watches_mutex: std.Thread.Mutex,
|
||||
// Per-directory snapshots of filenames, used to diff on NOTE_WRITE.
|
||||
// Key: owned dir path (same as watches key), value: set of owned filenames.
|
||||
// Key: independently owned dir path, value: set of owned filenames.
|
||||
// Accessed from both the main thread (add_watch) and the background thread (scan_dir).
|
||||
snapshots: std.StringHashMapUnmanaged(std.StringHashMapUnmanaged(void)),
|
||||
snapshots_mutex: std.Thread.Mutex,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ watches_mutex: std.Thread.Mutex,
|
|||
// Per-directory snapshots: owned filename -> mtime_ns.
|
||||
// Used to diff on NOTE_WRITE: detects creates, deletes, and (opportunistically)
|
||||
// modifications when the same directory fires another event later.
|
||||
// Key: owned dir path (same as watches key), value: map of owned filename -> mtime_ns.
|
||||
// Key: independently owned dir path, value: map of owned filename -> mtime_ns.
|
||||
snapshots: std.StringHashMapUnmanaged(std.StringHashMapUnmanaged(i128)),
|
||||
snapshots_mutex: std.Thread.Mutex,
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,13 @@ pub fn Create(comptime variant: Variant) type {
|
|||
/// was never watched. Does not unwatch subdirectories that were
|
||||
/// added automatically as a result of watching `path`.
|
||||
pub fn unwatch(self: *@This(), path: []const u8) UnwatchError!void {
|
||||
return self.interceptor.backend.remove_watch(self.allocator, path);
|
||||
// Normalize path the same way watch() does so that relative or
|
||||
// dot-containing paths resolve to the same key that was stored.
|
||||
const norm = std.fs.path.resolve(self.allocator, &.{path}) catch {
|
||||
return; // OOM: treat as no-op; path was never watched under the resolved form
|
||||
};
|
||||
defer self.allocator.free(norm);
|
||||
return self.interceptor.backend.remove_watch(self.allocator, norm);
|
||||
}
|
||||
|
||||
/// Read pending events from the backend fd and deliver them to the handler.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue