Skip to content

Commit 624b4f9

Browse files
authored
Merge pull request NarrativeScience-old#235 from NarrativeScience/fix/handle-file-remove
Gracefully handle file move/remove events
2 parents 95e25fd + a53f839 commit 624b4f9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

inputs/file/src/input.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ async function startFileWatcher(
8686
console.error(err)
8787
}
8888
})
89+
// If a file is removed (or moved), delete its file descriptor & size
90+
watcher.on('unlink', (filePath: string) => {
91+
delete fileSizes[filePath]
92+
delete fds[filePath]
93+
})
8994
}
9095

9196
/**

0 commit comments

Comments
 (0)