fix: normalize watch paths
This commit is contained in:
parent
f60f9e6a21
commit
190290e96c
1 changed files with 7 additions and 2 deletions
|
|
@ -169,9 +169,14 @@ pub fn Create(comptime variant: Variant) type {
|
|||
const cwd = std.fs.cwd().realpath(".", &cwd_buf) catch return error.WatchFailed;
|
||||
break :blk std.fmt.bufPrint(&buf, "{s}{c}{s}", .{ cwd, std.fs.path.sep, path }) catch return error.WatchFailed;
|
||||
};
|
||||
try self.interceptor.backend.add_watch(self.allocator, abs_path);
|
||||
// Collapse any . and .. segments without touching the filesystem so that
|
||||
// relative inputs like "../sibling" or "./sub" produce the same watch key
|
||||
// and event-path prefix as an equivalent absolute path would.
|
||||
const norm = std.fs.path.resolve(self.allocator, &.{abs_path}) catch return error.WatchFailed;
|
||||
defer self.allocator.free(norm);
|
||||
try self.interceptor.backend.add_watch(self.allocator, norm);
|
||||
if (!Backend.watches_recursively) {
|
||||
recurse_watch(&self.interceptor.backend, self.allocator, abs_path);
|
||||
recurse_watch(&self.interceptor.backend, self.allocator, norm);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue