send icon indicating copy to clipboard operation
send copied to clipboard

Open file with fs.open and use fs.fstat and createWriteStream(null, { fd })

Open ronag opened this issue 8 years ago • 1 comments

Open file with fs.open and use fs.fstat and fs.createReadStream(null, { fd }) otherwise we might have a race where the file at the specified path is replaced in the time between fs.stat and fs.createReadStream and wrong header data is provided.

ronag avatar Nov 25 '16 14:11 ronag

Have you actually run into this issue? The window of time for something like that to occur must be a few milliseconds at most. Switching to the method you suggest would add significant complexity to error handling because Node will not automatically close the file descriptor if an error occurs and failing to close the file descriptor will eventually lead to an EMFILE: too many open files error being thrown.

jcready avatar Dec 06 '16 15:12 jcready