Do not send first missing file event as well.

This commit is contained in:
Sheetal Nandi 2018-03-13 15:09:13 -07:00
parent 0f5166535e
commit cdf5b419f8

View File

@ -752,12 +752,17 @@ namespace ts {
};
function fileChanged(curr: any, prev: any) {
// previous event kind check is to ensure we recongnize the file as previously also missing when it is restored or renamed twice (that is it disappears and reappears)
// In such case, prevTime returned is same as prev time of event when file was deleted as per node documentation
const isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted;
if (+curr.mtime === 0) {
if (isPreviouslyDeleted) {
// Already deleted file, no need to callback again
return;
}
eventKind = FileWatcherEventKind.Deleted;
}
// previous event kind check is to ensure we send created event when file is restored or renamed twice (that is it disappears and reappears)
// since in that case the prevTime returned is same as prev time of event when file was deleted as per node documentation
else if (+prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted) {
else if (isPreviouslyDeleted) {
eventKind = FileWatcherEventKind.Created;
}
// If there is no change in modified time, ignore the event