aboutsummaryrefslogtreecommitdiff
path: root/src-self-hosted
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-08-07 22:12:47 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-08-07 22:14:30 -0400
commit60955feab82ef256a8983517f7435cde797c4e84 (patch)
tree10b78e4e2b09254e2777724955d6a96dd9b787b5 /src-self-hosted
parent5cbfe392beb26520554e7ec6ae7c67df47cc7e04 (diff)
downloadzig-60955feab82ef256a8983517f7435cde797c4e84.tar.gz
zig-60955feab82ef256a8983517f7435cde797c4e84.zip
std.event.fs.Watch distinguishes between Delete and CloseWrite on darwin
TODO: after 1 event emitted for a deleted file, the file is no longer watched
Diffstat (limited to 'src-self-hosted')
-rw-r--r--src-self-hosted/compilation.zig26
1 files changed, 11 insertions, 15 deletions
diff --git a/src-self-hosted/compilation.zig b/src-self-hosted/compilation.zig
index fd600bc558..712b3bbc87 100644
--- a/src-self-hosted/compilation.zig
+++ b/src-self-hosted/compilation.zig
@@ -758,32 +758,28 @@ pub const Compilation = struct {
// First, get an item from the watch channel, waiting on the channel.
var group = event.Group(BuildError!void).init(self.loop);
{
- const ev = await (async self.fs_watch.channel.get() catch unreachable);
- const root_scope = switch (ev) {
- fs.Watch(*Scope.Root).Event.CloseWrite => |x| x,
- fs.Watch(*Scope.Root).Event.Err => |err| {
- build_result = err;
- continue;
- },
+ const ev = (await (async self.fs_watch.channel.get() catch unreachable)) catch |err| {
+ build_result = err;
+ continue;
};
+ const root_scope = ev.data;
group.call(rebuildFile, self, root_scope) catch |err| {
build_result = err;
continue;
};
}
// Next, get all the items from the channel that are buffered up.
- while (await (async self.fs_watch.channel.getOrNull() catch unreachable)) |ev| {
- const root_scope = switch (ev) {
- fs.Watch(*Scope.Root).Event.CloseWrite => |x| x,
- fs.Watch(*Scope.Root).Event.Err => |err| {
+ while (await (async self.fs_watch.channel.getOrNull() catch unreachable)) |ev_or_err| {
+ if (ev_or_err) |ev| {
+ const root_scope = ev.data;
+ group.call(rebuildFile, self, root_scope) catch |err| {
build_result = err;
continue;
- },
- };
- group.call(rebuildFile, self, root_scope) catch |err| {
+ };
+ } else |err| {
build_result = err;
continue;
- };
+ }
}
build_result = await (async group.wait() catch unreachable);
}