0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

fixing bugs with streams

This commit is contained in:
Alex Kocharin 2013-07-12 23:51:04 +04:00
parent 593e6195c7
commit f19f523e1a

View file

@ -42,7 +42,7 @@ function write_stream(name) {
this.queue(data); this.queue(data);
}, function() { }, function() {
this.queue(null); this.queue(null);
}); }, {autoDestroy: false});
stream.pause(); stream.pause();
fs.exists(name, function(exists) { fs.exists(name, function(exists) {
@ -54,10 +54,13 @@ function write_stream(name) {
file.write(data); file.write(data);
}); });
stream.on('end', function() { stream.on('end', function() {
fs.rename(tmpname, name, function(err) { file.on('close', function() {
if (err) stream.emit('error', err); fs.rename(tmpname, name, function(err) {
stream.emit('close'); if (err) stream.emit('error', err);
stream.emit('close');
});
}); });
file.destroySoon();
}); });
stream.resume(); stream.resume();
}); });