@@ -178,6 +178,9 @@ export async function CommitIngestOperation(
178
178
// Ensure any adlibbed parts are updated to follow the segmentId of the previous part
179
179
await updateSegmentIdsForAdlibbedPartInstances ( context , ingestModel , beforePartMap )
180
180
181
+ if ( data . renamedSegments && data . renamedSegments . size > 0 ) {
182
+ logger . debug ( `Renamed segments: ${ JSON . stringify ( Array . from ( data . renamedSegments . entries ( ) ) ) } ` )
183
+ }
181
184
// ensure instances have matching segmentIds with the parts
182
185
await updatePartInstancesSegmentIds ( context , ingestModel , data . renamedSegments , beforePartMap )
183
186
@@ -397,6 +400,34 @@ async function updatePartInstancesSegmentIds(
397
400
}
398
401
}
399
402
if ( writeOps . length ) await context . directCollections . PartInstances . bulkWrite ( writeOps )
403
+
404
+ // Double check that there are no parts using the old segment ids:
405
+ const oldSegmentIds = Array . from ( renameRules . keys ( ) )
406
+ const [ badPartInstances , badParts ] = await Promise . all ( [
407
+ await context . directCollections . PartInstances . findFetch ( {
408
+ rundownId : ingestModel . rundownId ,
409
+ segmentId : { $in : oldSegmentIds } ,
410
+ } ) ,
411
+ await context . directCollections . Parts . findFetch ( {
412
+ rundownId : ingestModel . rundownId ,
413
+ segmentId : { $in : oldSegmentIds } ,
414
+ } ) ,
415
+ ] )
416
+ if ( badPartInstances . length > 0 ) {
417
+ logger . error (
418
+ `updatePartInstancesSegmentIds: Failed to update all PartInstances using old SegmentIds "${ JSON . stringify (
419
+ oldSegmentIds
420
+ ) } ": ${ JSON . stringify ( badPartInstances ) } , writeOps: ${ JSON . stringify ( writeOps ) } `
421
+ )
422
+ }
423
+
424
+ if ( badParts . length > 0 ) {
425
+ logger . error (
426
+ `updatePartInstancesSegmentIds: Failed to update all Parts using old SegmentIds "${ JSON . stringify (
427
+ oldSegmentIds
428
+ ) } ": ${ JSON . stringify ( badParts ) } , writeOps: ${ JSON . stringify ( writeOps ) } `
429
+ )
430
+ }
400
431
}
401
432
}
402
433
0 commit comments