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:
parent
593e6195c7
commit
f19f523e1a
1 changed files with 7 additions and 4 deletions
|
@ -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();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue