From babeb01ebe4f48dcf11cd7c6c8593fa10037c40f Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 12 Oct 2013 15:54:39 -0500 Subject: [PATCH] Add try-catch to playlist loading --- changelog | 4 ++++ lib/channel.js | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/changelog b/changelog index 1a131823..557392c7 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +Sat Oct 12 15:53 2013 CDT + * lib/channel.js: Add a try-catch to playlist loading to catch + the mysterious error that's been coming up (corrupt pl?) + Mon Oct 07 19:00 2013 CDT * lib/channel.js: Rearrange the callback order to prevent database lookups from racing with the playlist queue. diff --git a/lib/channel.js b/lib/channel.js index 556e0dae..af45ecd2 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -1599,16 +1599,22 @@ Channel.prototype.tryQueuePlaylist = function(user, data) { return; } - if (data.pos === "next") { - pl.reverse(); - if (self.playlist.items.length === 0) - pl.unshift(pl.pop()); - } + try { + if (data.pos === "next") { + pl.reverse(); + if (pl.length > 0 && self.playlist.items.length === 0) + pl.unshift(pl.pop()); + } - for (var i = 0; i < pl.length; i++) { - pl[i].pos = data.pos; - pl[i].temp = !self.hasPermission(user, "addnontemp"); - self.addMedia(pl[i], user); + for (var i = 0; i < pl.length; i++) { + pl[i].pos = data.pos; + pl[i].temp = !self.hasPermission(user, "addnontemp"); + self.addMedia(pl[i], user); + } + } catch (e) { + Logger.errlog.log("Loading user playlist failed!"); + Logger.errlog.log("PL: " + user.name + "-" + data.name); + Logger.errlog.log(e.stack); } }); }