Prevent server from infinite looping when google docs refresh fails

This commit is contained in:
Calvin Montgomery 2014-05-24 11:06:46 -07:00
parent f3eb999a76
commit 3cae0b0e57
1 changed files with 6 additions and 2 deletions

View File

@ -940,7 +940,7 @@ PlaylistModule.prototype.startPlayback = function (time) {
return; return;
} }
if (media.type === "gd" && !media.meta.object) { if (media.type === "gd" && !media.meta.object && !media.meta.failed) {
self.channel.activeLock.lock(); self.channel.activeLock.lock();
this.refreshGoogleDocs(function () { this.refreshGoogleDocs(function () {
self.channel.activeLock.release(); self.channel.activeLock.release();
@ -1039,6 +1039,7 @@ PlaylistModule.prototype.refreshGoogleDocs = function (cb) {
self._gdRefreshTimer = false; self._gdRefreshTimer = false;
if (self.current) { if (self.current) {
self.current.media.meta.object = self.current.media.meta.object || null; self.current.media.meta.object = self.current.media.meta.object || null;
self.current.media.meta.failed = true;
} }
if (cb) { if (cb) {
cb(); cb();
@ -1054,7 +1055,10 @@ PlaylistModule.prototype.refreshGoogleDocs = function (cb) {
if (err) { if (err) {
Logger.errlog.log("Google Docs autorefresh failed: " + err); Logger.errlog.log("Google Docs autorefresh failed: " + err);
Logger.errlog.log("ID was: " + self.current.media.id); Logger.errlog.log("ID was: " + self.current.media.id);
if (self.current) {
self.current.media.meta.object = self.current.media.meta.object || null; self.current.media.meta.object = self.current.media.meta.object || null;
self.current.media.meta.failed = true;
}
cb && cb(); cb && cb();
self.channel.activeLock.release(); self.channel.activeLock.release();
} else { } else {