Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: a better fix for the deleted PartInstance problem #1360

Open
wants to merge 2 commits into
base: release51
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions packages/job-worker/src/ingest/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { unprotectString, protectString } from '@sofie-automation/corelib/dist/p
import { logger } from '../logging'
import { PlayoutModel } from '../playout/model/PlayoutModel'
import { PlayoutRundownModel } from '../playout/model/PlayoutRundownModel'
import { isTooCloseToAutonext } from '../playout/lib'
import { allowedToMoveRundownOutOfPlaylist } from '../rundown'
import { updatePartInstanceRanksAndOrphanedState } from '../updatePartInstanceRanksAndOrphanedState'
import {
Expand Down Expand Up @@ -224,8 +223,6 @@ export async function CommitIngestOperation(
const pSaveIngest = ingestModel.saveAllToDatabase()
pSaveIngest.catch(() => null) // Ensure promise isn't reported as unhandled

ensureNextPartInstanceIsNotDeleted(playoutModel)

await validateAdlibTestingSegment(context, playoutModel)

try {
Expand Down Expand Up @@ -284,19 +281,9 @@ function canRemoveSegment(
logger.warn(`Not allowing removal of current playing segment "${segmentId}", making segment unsynced instead`)
return false
}
if (nextPartInstance?.segmentId === segmentId && isTooCloseToAutonext(currentPartInstance, false)) {
// Don't allow removing an active rundown
logger.warn(
`Not allowing removal of nexted segment "${segmentId}", because it's too close to an auto-next, making segment unsynced instead`
)
return false
}

if (nextPartInstance?.segmentId === segmentId && nextPartInstance.orphaned === 'adlib-part') {
if (nextPartInstance?.segmentId === segmentId) {
// Don't allow removing an active rundown
logger.warn(
`Not allowing removal of segment "${segmentId}" which contains nexted adlibbed part, making segment unsynced instead`
)
logger.warn(`Not allowing removal of nexted segment "${segmentId}", making segment unsynced instead`)
return false
}

Expand Down Expand Up @@ -855,12 +842,3 @@ async function validateAdlibTestingSegment(_context: JobContext, playoutModel: P
rundown.updateAdlibTestingSegmentRank()
}
}
function ensureNextPartInstanceIsNotDeleted(playoutModel: PlayoutModel) {
if (playoutModel.nextPartInstance) {
// Check if the segment of the nextPartInstance exists
if (!playoutModel.findSegment(playoutModel.nextPartInstance.partInstance.segmentId)) {
// The segment doesn't exist, set nextPartInstance to null, it'll be set by ensureNextPartIsValid() later.
playoutModel.setPartInstanceAsNext(null, false, false)
}
}
}
44 changes: 22 additions & 22 deletions packages/job-worker/src/ingest/updateNext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,28 @@ export async function ensureNextPartIsValid(context: JobContext, playoutModel: P
const orderedSegments = playoutModel.getAllOrderedSegments()
const orderedParts = playoutModel.getAllOrderedParts()

if (currentPartInstance && nextPartInstance) {
if (!nextPartInstance || nextPartInstance.partInstance.orphaned === 'deleted') {
// Don't have a nextPart or it has been deleted, so autoselect something
const newNextPart = selectNextPart(
context,
playlist,
currentPartInstance?.partInstance ?? null,
nextPartInstance?.partInstance ?? null,
orderedSegments,
orderedParts
)

if (!newNextPart && !playoutModel.playlist.nextPartInfo) {
// No currently nexted part, and nothing was selected, so nothing to update
span?.end()
return false
}

await setNextPart(context, playoutModel, newNextPart ?? null, false)

span?.end()
return true
} else if (currentPartInstance && nextPartInstance) {
// Check if the part is the same
const newNextPart = selectNextPart(
context,
Expand All @@ -70,27 +91,6 @@ export async function ensureNextPartIsValid(context: JobContext, playoutModel: P
span?.end()
return true
}
} else if (!nextPartInstance || nextPartInstance.partInstance.orphaned === 'deleted') {
// Don't have a nextPart or it has been deleted, so autoselect something
const newNextPart = selectNextPart(
context,
playlist,
currentPartInstance?.partInstance ?? null,
nextPartInstance?.partInstance ?? null,
orderedSegments,
orderedParts
)

if (!newNextPart && !playoutModel.playlist.nextPartInfo) {
// No currently nexted part, and nothing was selected, so nothing to update
span?.end()
return false
}

await setNextPart(context, playoutModel, newNextPart ?? null, false)

span?.end()
return true
}

span?.end()
Expand Down
Loading