mirror of https://github.com/calzoneman/sync.git
Fix bad MySQL results crashing it
This commit is contained in:
parent
3f843e9c8c
commit
baf52a2a78
|
@ -45,6 +45,10 @@ Channel.prototype.loadMysql = function() {
|
||||||
var query = 'SELECT * FROM channels WHERE name="{}"'
|
var query = 'SELECT * FROM channels WHERE name="{}"'
|
||||||
.replace(/\{\}/, this.name);
|
.replace(/\{\}/, this.name);
|
||||||
var results = db.querySync(query);
|
var results = db.querySync(query);
|
||||||
|
if(!results) {
|
||||||
|
console.log("channel query failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rows = results.fetchAllSync();
|
var rows = results.fetchAllSync();
|
||||||
if(rows.length == 0) {
|
if(rows.length == 0) {
|
||||||
console.log("Channel " + this.name + " is unregistered");
|
console.log("Channel " + this.name + " is unregistered");
|
||||||
|
@ -56,6 +60,10 @@ Channel.prototype.loadMysql = function() {
|
||||||
var query = 'SELECT * FROM chan_{}_library'
|
var query = 'SELECT * FROM chan_{}_library'
|
||||||
.replace(/\{\}/, this.name);
|
.replace(/\{\}/, this.name);
|
||||||
var results = db.querySync(query);
|
var results = db.querySync(query);
|
||||||
|
if(!results) {
|
||||||
|
console.log("channel library query failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rows = results.fetchAllSync();
|
var rows = results.fetchAllSync();
|
||||||
for(var i = 0; i < rows.length; i++) {
|
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);
|
this.library[rows[i].id] = new Media(rows[i].id, rows[i].title, rows[i].seconds, rows[i].type);
|
||||||
|
|
Loading…
Reference in New Issue