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

cleanup incomplete upload requests

This commit is contained in:
Alex Kocharin 2013-09-24 10:28:26 +04:00
parent 2ee792633c
commit bdd748c6e2
3 changed files with 22 additions and 0 deletions

View file

@ -62,6 +62,12 @@ function write_stream(name) {
});
file.destroySoon();
});
stream.on('abort', function() {
file.on('close', function() {
fs.unlink(tmpname);
});
file.destroy();
});
stream.resume();
});
return stream;

View file

@ -159,6 +159,18 @@ module.exports = function(config_hash) {
var stream = storage.add_tarball(name, req.params.filename);
req.pipe(stream);
// checking if end event came before closing
var complete = false;
req.on('end', function() {
complete = true;
});
req.on('close', function() {
if (!complete) {
stream.emit('abort');
}
});
stream.on('error', function(err) {
return next(err);
});

View file

@ -161,6 +161,10 @@ Storage.prototype.add_tarball = function(name, filename) {
wstream.on('close', function() {
stream.emit('end');
});
stream.on('abort', function() {
wstream.emit('abort');
});
return stream;
}