seedlinux

find open source torrents and stats for people wishing to contribute bandwidth.
git clone git://git.beardyjay.co.uk/seedlinux
Log | Files | Refs | README | LICENSE

commit 8165daca985eea209cedfd1d4f5e16eecd45616b
parent 0c1c45b700d9233039c19f016dc7f1fab60f84db
Author: Jay Scott <jay@beardyjay.co.uk>
Date:   Fri, 30 Jun 2017 13:01:49 +0100

Redirect when hash lookup results nothing

Diffstat:
Mcontrollers/torrents_controller.js | 13+++++++------
Mmodels/torrent_model.js | 2++
2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/controllers/torrents_controller.js b/controllers/torrents_controller.js @@ -13,11 +13,7 @@ exports.index = function(req, res) { Torrent.find({},callback); }, }, function(err, results) { - if(!results) { - console.log(results.torrent_count); - results.torrent_count == 0; - } - res.render('torrent', { title: 'Index Page', error: err, data: results }); + res.render('torrent', { title: 'Index Page', data: results }); }); }; @@ -30,6 +26,11 @@ exports.torrent_detail = function(req, res) { Torrent.find({hash: req.params.id},callback); }, }, function(err, results) { - res.render('details', { title: 'Torrent Details', error: err, data: results }); + if(results.torrent_data == "" ) { + console.log(results); + res.redirect('/torrent'); + } else { + res.render('details', { title: 'Torrent Details', data: results }); + } }); }; diff --git a/models/torrent_model.js b/models/torrent_model.js @@ -3,6 +3,8 @@ const mongoose = require('mongoose'); const Schema = mongoose.Schema; +mongoose.Promise = global.Promise; + const TorrentSchema = Schema( { name: {type: String, required: true, max: 100},