Finished optimizing automated queue transactions.
This commit is contained in:
parent
dd36b1d923
commit
75301ec7d9
|
|
@ -360,7 +360,6 @@ class queue{
|
|||
chanDB.media.liveRemainder = this.nowPlaying.uuid;
|
||||
|
||||
//Save the chanDB
|
||||
console.log("Saving db from goLive() :363");
|
||||
await chanDB.save();
|
||||
}
|
||||
|
||||
|
|
@ -593,12 +592,12 @@ 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, true);
|
||||
await this.removeMedia(item.uuid, socket, chanDB, true, 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);
|
||||
await this.end(false, true, false, chanDB, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -609,7 +608,8 @@ class queue{
|
|||
//Refresh next timer
|
||||
await this.refreshNextTimer();
|
||||
|
||||
console.log("Saved by removeRange() :599");
|
||||
//Broadcast Queue
|
||||
await this.broadcastQueue(chanDB);
|
||||
|
||||
}catch(err){
|
||||
//If this was originated by someone
|
||||
|
|
@ -749,9 +749,10 @@ class queue{
|
|||
* @param {Socket} socket - Requesting Socket
|
||||
* @param {Mongoose.Document} chanDB - Channnel Document Passthrough to save on DB Access
|
||||
* @param {Boolean} noScheduling - Disables schedule timer refresh and this.save() calls if true, good for internal function calls
|
||||
* @param {Boolean} noBroadcast - Disables schedule broadcasting to clients, good for internal function calls
|
||||
* @returns {Media} Deleted Media Item
|
||||
*/
|
||||
async removeMedia(uuid, socket, chanDB, noScheduling = false){
|
||||
async removeMedia(uuid, socket, chanDB, noScheduling = false, noBroadcast = false){
|
||||
//If we're streamlocked
|
||||
if(this.streamLock){
|
||||
//If an originating socket was provided for this request
|
||||
|
|
@ -798,13 +799,15 @@ class queue{
|
|||
}
|
||||
//Otherwise
|
||||
}else{
|
||||
//Broadcast changes
|
||||
this.broadcastQueue(chanDB);
|
||||
//If broadcasting is enabled
|
||||
if(!noBroadcast){
|
||||
//Broadcast changes
|
||||
this.broadcastQueue(chanDB);
|
||||
}
|
||||
|
||||
//If saving is disabled
|
||||
if(!noScheduling){
|
||||
//Save changes to the DB
|
||||
console.log("Saving db from removeMedia() :792");
|
||||
await chanDB.save();
|
||||
}
|
||||
}
|
||||
|
|
@ -861,16 +864,21 @@ 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();
|
||||
}
|
||||
|
||||
//Broadcast the channel
|
||||
this.broadcastQueue(chanDB);
|
||||
//If broadcasting is enabled
|
||||
if(!noBroadcast){
|
||||
//Broadcast the channel
|
||||
this.broadcastQueue(chanDB);
|
||||
}
|
||||
|
||||
}catch(err){
|
||||
//Broadcast the channel
|
||||
this.broadcastQueue();
|
||||
//If broadcasting is enabled
|
||||
if(!noBroadcast){
|
||||
//Broadcast the channel
|
||||
this.broadcastQueue();
|
||||
}
|
||||
|
||||
//If this was originated by someone
|
||||
if(socket != null){
|
||||
|
|
@ -1052,7 +1060,6 @@ 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();
|
||||
}
|
||||
|
|
@ -1149,9 +1156,6 @@ class queue{
|
|||
return record.uuid != mediaObj.uuid;
|
||||
});
|
||||
|
||||
|
||||
console.log("Saving db from start() :1138");
|
||||
|
||||
//Save the channel
|
||||
await chanDB.save();
|
||||
|
||||
|
|
@ -1286,9 +1290,6 @@ 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();
|
||||
}
|
||||
|
|
@ -1318,7 +1319,6 @@ 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
|
||||
|
|
@ -1385,9 +1385,6 @@ 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();
|
||||
|
||||
|
|
@ -1509,7 +1506,7 @@ class queue{
|
|||
const mediaObj = entry[1];
|
||||
|
||||
//Remove media from queue without calling chanDB.save() to make room before we move everything
|
||||
await this.removeMedia(mediaObj.uuid, null, chanDB, true);
|
||||
await this.removeMedia(mediaObj.uuid, null, chanDB, true, true);
|
||||
|
||||
mediaObj.genUUID();
|
||||
|
||||
|
|
@ -1525,6 +1522,9 @@ class queue{
|
|||
|
||||
//Schedule the moved schedule, letting scheduleMedia save our changes for us, starting w/o saves to prevent over-saving
|
||||
await this.scheduleMedia(newSched, null, chanDB);
|
||||
|
||||
//Broadcast the queue now that everything is hunky dory
|
||||
await this.broadcastQueue(chanDB);
|
||||
}catch(err){
|
||||
//Null out live remainder for the next stream
|
||||
this.liveRemainder = null;
|
||||
|
|
@ -1881,9 +1881,6 @@ 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()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue