fix: make sure paths are absolute before watching them

This commit is contained in:
CJ van den Berg 2026-03-07 20:32:13 +01:00
parent 3554794234
commit 8ad17f5189
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -75,9 +75,11 @@ pub fn deinit(self: *@This()) void {
/// all subdirectories are watched recursively and new directories created /// all subdirectories are watched recursively and new directories created
/// inside are watched automatically. /// inside are watched automatically.
pub fn watch(self: *@This(), path: []const u8) Error!void { pub fn watch(self: *@This(), path: []const u8) Error!void {
try self.interceptor.backend.add_watch(self.allocator, path); var buf: [std.fs.max_path_bytes]u8 = undefined;
const abs_path = std.fs.cwd().realpath(path, &buf) catch return error.WatchFailed;
try self.interceptor.backend.add_watch(self.allocator, abs_path);
if (!Backend.watches_recursively) { if (!Backend.watches_recursively) {
recurse_watch(&self.interceptor.backend, self.allocator, path); recurse_watch(&self.interceptor.backend, self.allocator, abs_path);
} }
} }