Skip to content

Commit 6b680d8

Browse files
authored
feat: add piece status to indicate invalid package container source SOFIE-2991 (#14) (Sofie-Automation#1551)
1 parent 8b07493 commit 6b680d8

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

meteor/server/publications/packageManager/expectedPackages/generate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ function generateExpectedPackageForDevice(
194194
if (lookedUpSource) {
195195
combinedSources.push(calculateCombinedSource(packageSource, lookedUpSource))
196196
} else {
197-
logger.warn(
198-
`Pub.expectedPackagesForDevice: Source package container "${packageSource.containerId}" not found`
199-
)
197+
// This can happen if the blueprints reference a Package Container that is for another studio.
198+
// checkPieceContentStatus will formulate a proper status for this situation
199+
200200
// Add a placeholder source, it's used to provide users with a hint of what's wrong
201201
combinedSources.push({
202202
containerId: packageSource.containerId,

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,26 @@ async function checkPieceContentExpectedPackageStatus(
669669
}
670670
}
671671

672+
const fileName = getExpectedPackageFileName(expectedPackage) ?? ''
673+
674+
// Check if any of the sources exist and are valid
675+
// Future: This might be better to do by passing packageManager an 'forcedError' property in the publication, but this direct check is simpler and enough for now
676+
const hasValidSources =
677+
expectedPackage.sources &&
678+
(expectedPackage.sources.length === 0 ||
679+
!expectedPackage.sources.find((source) => !studio.packageContainers[source.containerId]))
680+
if (!hasValidSources) {
681+
// The expected package has no valid sources
682+
683+
pushOrMergeMessage({
684+
status: PieceStatusCode.SOURCE_MISSING,
685+
message: PackageStatusMessage.FILE_MISSING_SOURCE_CONTAINERS,
686+
fileName: fileName,
687+
packageContainers: expectedPackage.sources.map((s) => s.containerId), // Ideally this would be labels, but the containers are missing
688+
})
689+
continue
690+
}
691+
672692
let warningMessage: ContentMessageLight | null = null
673693
let matchedExpectedPackageId: ExpectedPackageId | null = null
674694
for (const expectedPackageId of expectedPackageIds) {
@@ -712,7 +732,6 @@ async function checkPieceContentExpectedPackageStatus(
712732
break
713733
}
714734

715-
const fileName = getExpectedPackageFileName(expectedPackage) ?? ''
716735
const containerLabel = matchedPackageContainer[1].container.label
717736

718737
if (!matchedExpectedPackageId || warningMessage) {

meteor/server/publications/pieceContentStatusUI/messageFactory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const DEFAULT_MESSAGES: Record<PackageStatusMessage, ITranslatableMessage> = {
1616
[PackageStatusMessage.FILE_IS_MISSING]: generateTranslation('{{sourceLayer}} is missing'),
1717

1818
// Package manager
19+
[PackageStatusMessage.FILE_MISSING_SOURCE_CONTAINERS]: generateTranslation(
20+
'{{sourceLayer}} has unsupported source: {{containerLabels}}'
21+
),
1922
[PackageStatusMessage.FILE_CANT_BE_FOUND_ON_PLAYOUT_SYSTEM]: generateTranslation(
2023
`{{sourceLayer}} can't be found on the playout system`
2124
),

packages/shared-lib/src/packageStatusMessages.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export enum PackageStatusMessage {
3333
FILE_IS_MISSING = 'FILE_IS_MISSING',
3434

3535
// Package manager
36+
/**
37+
* The file has no valid source package containers
38+
*/
39+
FILE_MISSING_SOURCE_CONTAINERS = 'FILE_MISSING_SOURCE_CONTAINERS',
3640
/**
3741
* The file can't be found on the playout system
3842
*/

0 commit comments

Comments
 (0)