diff --git a/src/app/channel/media/queue.js b/src/app/channel/media/queue.js index 3905702..d76a92a 100644 --- a/src/app/channel/media/queue.js +++ b/src/app/channel/media/queue.js @@ -360,6 +360,7 @@ class queue{ chanDB.media.liveRemainder = this.nowPlaying.uuid; //Save the chanDB + console.log("Saving db from goLive() :363"); await chanDB.save(); } @@ -592,9 +593,24 @@ class queue{ //For each item for(let item of foundItems){ //Remove media, passing down chanDB so we're not looking again and again - await this.removeMedia(item.uuid, socket, chanDB); + await this.removeMedia(item.uuid, socket, chanDB, true); + + //If this is the current item + if(this.nowPlaying != null && item.uuid == this.nowPlaying.uuid){ + //End it + await this.end(false, true, false, chanDB); + } } + + //Save data to channe database + await chanDB.save(); + + //Refresh next timer + await this.refreshNextTimer(); + + console.log("Saved by removeRange() :599"); + }catch(err){ //If this was originated by someone if(socket != null){ @@ -788,6 +804,7 @@ class queue{ //If saving is disabled if(!noScheduling){ //Save changes to the DB + console.log("Saving db from removeMedia() :792"); await chanDB.save(); } } @@ -844,6 +861,7 @@ class queue{ //If saving is enabled (seperate from all DB transactions since caller function may want modifications but handle saving on its own) if(!noScheduling){ + console.log("Saving db from removeMedia() :849"); await chanDB.save(); } @@ -1034,6 +1052,7 @@ class queue{ try{ //If saving is enabled (seperate from all DB transactions since caller function may want modifications but handle saving on its own) if(!noSave){ + console.log("Saving db from scheduleMedia() :1040"); //Save the database await chanDB.save(); } @@ -1130,6 +1149,9 @@ class queue{ return record.uuid != mediaObj.uuid; }); + + console.log("Saving db from start() :1138"); + //Save the channel await chanDB.save(); @@ -1264,6 +1286,9 @@ class queue{ //broadcast queue using unsaved archive, run this before chanDB.save() for better responsiveness this.broadcastQueue(chanDB); + + console.log("Saving db from end() :1275"); + //Save our changes to the DB await chanDB.save(); } @@ -1293,6 +1318,7 @@ class queue{ } //Disable stream lock this.streamLock = false; + console.log("testem"); //We don't have to save here since someone else will do it for us :) //Reminder for those of us reading this in the future since I'm a dipshit: this only clears the DB liveRemainder, NOT the RAM backed variable @@ -1359,6 +1385,9 @@ class queue{ //Throw the livestream into the archive chanDB.media.archived.push(wasPlaying); + + console.log("Saving db from livestreamOverwriteSchedule() :1373"); + //Save the DB await chanDB.save(); @@ -1852,6 +1881,9 @@ class queue{ //Update schedule to only contain what hasn't been played yet chanDB.media.scheduled = newSched; + + console.log("Saving db from rehydrateQueue() :1869"); + //Save the DB await chanDB.save()