Just open a stream using createWriteStream and wait for events without 
piping anything. If you get 'open' event, start your pipe. If you get 
'error' event, create directory and repeat.

There is no need to re-pipe anything in this use-case.

On Thursday, September 26, 2013 11:48:26 PM UTC+4, [email protected] 
wrote:
>
> I'm doing a file copy using fs.createReadStream & fs.createWriteStream. 
> When write stream throws an ENOENT error because destination directory 
> doesn't exist, I want to create it, and than re-create and re-pipe the 
> streams.
>
> To do that, first I need to kill & get rid of already existing streams 
> without them causing any more issues and not breaking the app. Currently, 
> I'm doing this: http://hastebin.com/qeketakofi.js
>
> Bu I don't know whether some lines inside terminate() are not redundant, 
> or whether I'm not doing something that I should. Node docs are generally 
> quite brief, leaving tons of questions unanswered :/
>
> Also, for the sake of efficiency, is it possible to just recycle the read 
> stream, and pipe it to a new write stream?
>

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to