Fix bug in watchDirectory.