Send success response at once for mod download and update

This avoids browser retrying the request if download takes too long
This commit is contained in:
Björn Dahlgren 2015-12-29 16:19:55 +01:00
parent e72b4f65ce
commit 061d6c85e8
2 changed files with 8 additions and 15 deletions

View File

@ -47,7 +47,10 @@ Mods.prototype.download = function (mod, cb) {
self.emit('mods', self.mods);
}
self.updateMods();
cb(err, mods);
if (cb) {
cb(err, mods);
}
}).on('progress', function (progress) {
var modName = progress.mod;

View File

@ -5,13 +5,8 @@ module.exports = function (modsManager) {
},
create: function(req, res){
modsManager.download(req.body.name, function (err, mods) {
if (err || !mods) {
res.send(500, err);
} else {
res.send(mods);
}
});
modsManager.download(req.body.name);
res.send(204, {});
},
show: function(req, res){
@ -26,13 +21,8 @@ module.exports = function (modsManager) {
},
update: function(req, res){
modsManager.download(req.params.mod, function (err, mods) {
if (err || !mods) {
res.send(500, err);
} else {
res.send(mods);
}
});
modsManager.download(req.params.mod);
res.send(204, {});
},
destroy: function(req, res){