Really curious about this. Also fsync or not? Is this controllable via api?
Sent from my iPhone On Sep 25, 2012, at 4:24 PM, Mikeal Rogers <[email protected]> wrote: > I *think* he wants to wait until the data is flushed to disc before returning > a 201 or some such thing to an API client. > > On Sep 24, 2012, at September 24, 20129:20 PM, Ben Noordhuis > <[email protected]> wrote: > >> On Sun, Sep 23, 2012 at 6:52 PM, Andris Reinman >> <[email protected]> wrote: >>> What would be the best way to detect a file has been written to disk? Once I >>> have passed all the data to a fs.WriteStream, the data is at first buffered >>> by node and written to the disk asynchronously. There is no "end" or "close" >>> event to listen to (or at least these don't trigger on my system (node >>> v0.8.9)) when all bytes are actually written to the disk. >>> >>> The best I have come up to is to listen to the "drain" event and then >>> compare writablestream.bytesWritten and the length of the data I sent to the >>> stream. >>> >>> var len = 0; >>> myReadStream.on("data", function(chunk){ >>> myWriteStream.write(chunk); >>> len += chunk.length; >>> }); >>> >>> myWriteStream.on("drain", function(){ >>> if(myWriteStream.bytesWritten == len){ >>> console.log("All bytes written to disk"); >>> } >>> }); >>> >>> But this doesn't seem very future proof, what if the conditions for the >>> 'drain' event with file write change one day? Is there a better way for >>> this? >> >> Doesn't myReadStream.pipe(myWriteStream) work? >> >> -- >> Job Board: http://jobs.nodejs.org/ >> Posting guidelines: >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >> You received this message because you are subscribed to the Google >> Groups "nodejs" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
