mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-04-13 23:47:48 +02:00
fix(core): fixed all res.send(message) of not found from db by id
This commit is contained in:
@@ -330,9 +330,7 @@ exports.makerByID = function (req, res, next, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (!maker) {
|
||||
return res.status(404).send({
|
||||
message: 'No maker with that identifier has been found'
|
||||
});
|
||||
return res.status(404).send();
|
||||
}
|
||||
req.maker = maker;
|
||||
next();
|
||||
|
||||
@@ -326,9 +326,7 @@ exports.collectionByID = function (req, res, next, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (!coll) {
|
||||
return res.status(404).send({
|
||||
message: 'No collection with that identifier has been found'
|
||||
});
|
||||
return res.status(404).send();
|
||||
}
|
||||
req.collection = coll;
|
||||
next();
|
||||
|
||||
@@ -187,9 +187,7 @@ exports.forumByID = function (req, res, next, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (!forum) {
|
||||
return res.status(404).send({
|
||||
message: 'No forum with that identifier has been found'
|
||||
});
|
||||
return res.status(404).send();
|
||||
}
|
||||
req.forum = forum;
|
||||
next();
|
||||
|
||||
@@ -1065,9 +1065,7 @@ exports.topicById = function (req, res, next, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (!topic) {
|
||||
return res.status(404).send({
|
||||
message: 'No topic with that identifier has been found'
|
||||
});
|
||||
return res.status(404).send();
|
||||
}
|
||||
req.topic = topic;
|
||||
next();
|
||||
|
||||
@@ -462,9 +462,7 @@ exports.invitationByID = function (req, res, next, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (!invitation) {
|
||||
return res.status(404).send({
|
||||
message: 'No invitation with that identifier has been found'
|
||||
});
|
||||
return res.status(404).send();
|
||||
}
|
||||
req.invitation = invitation;
|
||||
next();
|
||||
|
||||
@@ -107,9 +107,7 @@ exports.adminMessageByID = function (req, res, next, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (!message) {
|
||||
return res.status(404).send({
|
||||
message: 'No message with that identifier has been found'
|
||||
});
|
||||
return res.status(404).send();
|
||||
}
|
||||
req.adminMessage = message;
|
||||
next();
|
||||
|
||||
@@ -357,9 +357,7 @@ exports.messageByID = function (req, res, next, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (!message) {
|
||||
return res.status(404).send({
|
||||
message: 'No message with that identifier has been found'
|
||||
});
|
||||
return res.status(404).send();
|
||||
}
|
||||
req.message = message;
|
||||
next();
|
||||
|
||||
@@ -327,9 +327,7 @@ exports.requestByID = function (req, res, next, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (!request) {
|
||||
return res.status(404).send({
|
||||
message: 'No request with that identifier has been found'
|
||||
});
|
||||
return res.status(404).send();
|
||||
}
|
||||
req.request = request;
|
||||
next();
|
||||
|
||||
@@ -115,9 +115,7 @@ exports.completeByID = function (req, res, next, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (!complete) {
|
||||
return res.status(404).send({
|
||||
message: 'No complete with that identifier has been found'
|
||||
});
|
||||
return res.status(404).send();
|
||||
}
|
||||
req.complate = complete;
|
||||
next();
|
||||
|
||||
@@ -2103,7 +2103,7 @@ exports.torrentByID = function (req, res, next, id) {
|
||||
};
|
||||
|
||||
var findOtherTorrents = function (torrent, callback) {
|
||||
if (torrent.resource_detail_info.id) {
|
||||
if (torrent && torrent.resource_detail_info.id) {
|
||||
var condition = {
|
||||
torrent_status: 'reviewed',
|
||||
'resource_detail_info.id': torrent.resource_detail_info.id
|
||||
@@ -2136,33 +2136,40 @@ exports.torrentByID = function (req, res, next, id) {
|
||||
};
|
||||
|
||||
var writeAllFiles = function (torrent, callback) {
|
||||
var filePath = config.uploads.torrent.file.dest + torrent.torrent_filename;
|
||||
nt.read(filePath, function (err, torrent_data) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
var mdata = torrent_data.metadata;
|
||||
torrent._all_files = [];
|
||||
|
||||
if (mdata.info.files) {
|
||||
mdata.info.files.forEach(function (f) {
|
||||
torrent._all_files.push(f.path.join('/') + ', ' + common.fileSizeFormat(f.length, 2));
|
||||
});
|
||||
if (torrent) {
|
||||
var filePath = config.uploads.torrent.file.dest + torrent.torrent_filename;
|
||||
nt.read(filePath, function (err, torrent_data) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
torrent._all_files.push(mdata.info.name + ', ' + common.fileSizeFormat(mdata.info.length, 2));
|
||||
var mdata = torrent_data.metadata;
|
||||
torrent._all_files = [];
|
||||
|
||||
if (mdata.info.files) {
|
||||
mdata.info.files.forEach(function (f) {
|
||||
torrent._all_files.push(f.path.join('/') + ', ' + common.fileSizeFormat(f.length, 2));
|
||||
});
|
||||
} else {
|
||||
torrent._all_files.push(mdata.info.name + ', ' + common.fileSizeFormat(mdata.info.length, 2));
|
||||
}
|
||||
|
||||
callback(null, torrent);
|
||||
}
|
||||
|
||||
callback(null, torrent);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
} else {
|
||||
callback(null, torrent);
|
||||
}
|
||||
};
|
||||
|
||||
async.waterfall([findTorrents, findOtherTorrents, writeAllFiles], function (err, torrent) {
|
||||
if (err) {
|
||||
next(err);
|
||||
} else {
|
||||
req.torrent = torrent;
|
||||
if (torrent) {
|
||||
req.torrent = torrent;
|
||||
} else {
|
||||
return res.status(404).send();
|
||||
}
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -134,9 +134,7 @@ exports.traceByID = function (req, res, next, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (!trace) {
|
||||
return res.status(404).send({
|
||||
message: 'No trace with that identifier has been found'
|
||||
});
|
||||
return res.status(404).send();
|
||||
}
|
||||
req.trace = trace;
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user