diff --git a/lib/compiler/build_runner.zig b/lib/compiler/build_runner.zig index 990eb1b4ba..b11ca783cc 100644 --- a/lib/compiler/build_runner.zig +++ b/lib/compiler/build_runner.zig @@ -419,7 +419,7 @@ pub fn main() !void { std.posix.fanotify_mark(w.fan_fd, .{ .ADD = true, .ONLYDIR = true, - }, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOpt()) catch |err| { + }, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOrDot()) catch |err| { fatal("unable to watch {}: {s}", .{ path, @errorName(err) }); }; @@ -471,7 +471,7 @@ pub fn main() !void { try std.posix.fanotify_mark(w.fan_fd, .{ .REMOVE = true, .ONLYDIR = true, - }, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOpt()); + }, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOrDot()); w.dir_table.swapRemoveAt(i); w.handle_table.swapRemoveAt(i); diff --git a/lib/std/Build/Cache/Path.zig b/lib/std/Build/Cache/Path.zig index f6e469c254..c7160ea143 100644 --- a/lib/std/Build/Cache/Path.zig +++ b/lib/std/Build/Cache/Path.zig @@ -173,6 +173,10 @@ pub fn subPathOpt(self: Path) ?[]const u8 { return if (self.sub_path.len == 0) null else self.sub_path; } +pub fn subPathOrDot(self: Path) []const u8 { + return if (self.sub_path.len == 0) "." else self.sub_path; +} + /// Useful to make `Path` a key in `std.ArrayHashMap`. pub const TableAdapter = struct { pub const Hash = std.hash.Wyhash;