Skip to content

Commit

Permalink
Merge pull request #687 from BridgeAR/fix-no-callback
Browse files Browse the repository at this point in the history
Add callbacks to fs.close
  • Loading branch information
paulmillr committed Mar 11, 2018
2 parents a95a1f8 + df88ff0 commit dac69b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions lib/fsevents-handler.js
Expand Up @@ -213,9 +213,15 @@ function(watchPath, realPath, transform, globFilter) {
}
function checkFd() {
fs.open(path, 'r', function(error, fd) {
if (fd) fs.close(fd);
error && error.code !== 'EACCES' ?
handleEvent('unlink') : addOrChange();
if (error) {
error.code !== 'EACCES' ?
handleEvent('unlink') : addOrChange();
} else {
fs.close(fd, function(err) {
err && err.code !== 'EACCES' ?
handleEvent('unlink') : addOrChange();
});
}
});
}
// correct for wrong events emitted
Expand Down
5 changes: 3 additions & 2 deletions lib/nodefs-handler.js
Expand Up @@ -90,8 +90,9 @@ function setFsWatchListener(path, fullPath, options, handlers) {
// Workaround for https://github.com/joyent/node/issues/4337
if (process.platform === 'win32' && error.code === 'EPERM') {
fs.open(path, 'r', function(err, fd) {
if (fd) fs.close(fd);
if (!err) broadcastErr(error);
if (!err) fs.close(fd, function(err) {
if (!err) broadcastErr(error);
});
});
} else {
broadcastErr(error);
Expand Down

0 comments on commit dac69b6

Please sign in to comment.