Skip to content

Commit

Permalink
fix: thumbnail and scrub previews being reported as available too early
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 28, 2024
1 parent 3158b09 commit 391bfc4
Showing 1 changed file with 36 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,31 +528,25 @@ async function checkPieceContentExpectedPackageStatus(
if (!thumbnailUrl) {
const sideEffect = getSideEffect(expectedPackage, studio)

const packageThumbnailPath = sideEffect.thumbnailPackageSettings?.path
const thumbnailContainerId = sideEffect.thumbnailContainerId
if (packageThumbnailPath && thumbnailContainerId) {
thumbnailUrl = getAssetUrlFromExpectedPackages(
packageThumbnailPath,
thumbnailContainerId,
studio,
packageOnPackageContainer
)
}
thumbnailUrl = await getAssetUrlFromPackageContainerStatus(

Check warning on line 531 in meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts#L511-L531

Added lines #L511 - L531 were not covered by tests
studio,
getPackageContainerPackageStatus,
expectedPackageId,
sideEffect.thumbnailContainerId,
sideEffect.thumbnailPackageSettings?.path

Check warning on line 536 in meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts#L533-L536

Added lines #L533 - L536 were not covered by tests
)
}

if (!previewUrl) {
const sideEffect = getSideEffect(expectedPackage, studio)

Check warning on line 541 in meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts#L540-L541

Added lines #L540 - L541 were not covered by tests

const packagePreviewPath = sideEffect.previewPackageSettings?.path
const previewContainerId = sideEffect.previewContainerId
if (packagePreviewPath && previewContainerId) {
previewUrl = getAssetUrlFromExpectedPackages(
packagePreviewPath,
previewContainerId,
studio,
packageOnPackageContainer
)
}
previewUrl = await getAssetUrlFromPackageContainerStatus(

Check warning on line 543 in meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts#L543

Added line #L543 was not covered by tests
studio,
getPackageContainerPackageStatus,
expectedPackageId,
sideEffect.previewContainerId,
sideEffect.previewPackageSettings?.path

Check warning on line 548 in meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts#L545-L548

Added lines #L545 - L548 were not covered by tests
)
}

warningMessage = getPackageWarningMessage(packageOnPackageContainer, sourceLayer)
Expand Down Expand Up @@ -678,15 +672,32 @@ async function checkPieceContentExpectedPackageStatus(
}
}

async function getAssetUrlFromPackageContainerStatus(
studio: PieceContentStatusStudio,
getPackageContainerPackageStatus: (
packageContainerId: string,
expectedPackageId: ExpectedPackageId
) => Promise<PackageContainerPackageStatusLight | undefined>,
expectedPackageId: ExpectedPackageId,
assetContainerId: string | null | undefined,
packageAssetPath: string | undefined
): Promise<string | undefined> {
if (!assetContainerId || !packageAssetPath) return

const assetPackageContainer = studio.packageContainers[assetContainerId]
if (!assetPackageContainer) return

const previewPackageOnPackageContainer = await getPackageContainerPackageStatus(assetContainerId, expectedPackageId)
if (!previewPackageOnPackageContainer) return

return getAssetUrlFromExpectedPackages(packageAssetPath, assetPackageContainer, previewPackageOnPackageContainer)
}

Check warning on line 694 in meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts#L675-L694

Added lines #L675 - L694 were not covered by tests

function getAssetUrlFromExpectedPackages(
assetPath: string,
assetContainerId: string,
studio: PieceContentStatusStudio,
packageContainer: StudioPackageContainer,

Check warning on line 698 in meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts#L698

Added line #L698 was not covered by tests
packageOnPackageContainer: Pick<PackageContainerPackageStatusDB, 'status'>
): string | undefined {
const packageContainer = studio.packageContainers[assetContainerId]
if (!packageContainer) return

if (packageOnPackageContainer.status.status !== ExpectedPackageStatusAPI.PackageContainerPackageStatusStatus.READY)
return

Expand Down

0 comments on commit 391bfc4

Please sign in to comment.