Fix bad MySQL results crashing it

This commit is contained in:
calzoneman 2013-03-18 12:17:56 -05:00
parent 3f843e9c8c
commit baf52a2a78
2 changed files with 16 additions and 0 deletions

View file

@ -45,6 +45,10 @@ Channel.prototype.loadMysql = function() {
var query = 'SELECT * FROM channels WHERE name="{}"'
.replace(/\{\}/, this.name);
var results = db.querySync(query);
if(!results) {
console.log("channel query failed");
return;
}
var rows = results.fetchAllSync();
if(rows.length == 0) {
console.log("Channel " + this.name + " is unregistered");
@ -56,6 +60,10 @@ Channel.prototype.loadMysql = function() {
var query = 'SELECT * FROM chan_{}_library'
.replace(/\{\}/, this.name);
var results = db.querySync(query);
if(!results) {
console.log("channel library query failed");
return;
}
var rows = results.fetchAllSync();
for(var i = 0; i < rows.length; i++) {
this.library[rows[i].id] = new Media(rows[i].id, rows[i].title, rows[i].seconds, rows[i].type);

8
run.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
while :
do
node server.js
sleep 2
done