@@ -18,13 +18,14 @@ import { deferAsync, normalizeArrayToMap } from '@sofie-automation/corelib/dist/
1818import { getCoreSystemAsync } from './coreSystem/collection'
1919import { cleanupOldDataInner } from './api/cleanup'
2020import { CollectionCleanupResult } from '@sofie-automation/meteor-lib/dist/api/system'
21- import { ICoreSystem } from '@sofie-automation/meteor -lib/dist/collections/CoreSystem '
21+ import { ICoreSystemSettings } from '@sofie-automation/shared -lib/dist/core/model/CoreSystemSettings '
2222import { executePeripheralDeviceFunctionWithCustomTimeout } from './api/peripheralDevice/executeFunction'
2323import {
2424 interpollateTranslation ,
2525 isTranslatableMessage ,
2626 translateMessage ,
2727} from '@sofie-automation/corelib/dist/TranslatableMessage'
28+ import { applyAndValidateOverrides } from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
2829
2930const lowPrioFcn = ( fcn : ( ) => any ) => {
3031 // Do it at a random time in the future:
@@ -49,15 +50,17 @@ export async function nightlyCronjobInner(): Promise<void> {
4950 logger . info ( 'Nightly cronjob: starting...' )
5051 const system = await getCoreSystemAsync ( )
5152
53+ const systemSettings = system && applyAndValidateOverrides ( system . settingsWithOverrides ) . obj
54+
5255 await Promise . allSettled ( [
5356 cleanupOldDataCronjob ( ) . catch ( ( error ) => {
5457 logger . error ( `Cronjob: Error when cleaning up old data: ${ stringifyError ( error ) } ` )
5558 logger . error ( error )
5659 } ) ,
57- restartCasparCG ( system , previousLastNightlyCronjob ) . catch ( ( e ) => {
60+ restartCasparCG ( systemSettings , previousLastNightlyCronjob ) . catch ( ( e ) => {
5861 logger . error ( `Cron: Restart CasparCG error: ${ stringifyError ( e ) } ` )
5962 } ) ,
60- storeSnapshots ( system ) . catch ( ( e ) => {
63+ storeSnapshots ( systemSettings ) . catch ( ( e ) => {
6164 logger . error ( `Cron: Rundown Snapshots error: ${ stringifyError ( e ) } ` )
6265 } ) ,
6366 ] )
@@ -81,8 +84,8 @@ async function cleanupOldDataCronjob() {
8184
8285const CASPARCG_LAST_SEEN_PERIOD_MS = 3 * 60 * 1000 // Note: this must be higher than the ping interval used by playout-gateway
8386
84- async function restartCasparCG ( system : ICoreSystem | undefined , previousLastNightlyCronjob : number ) {
85- if ( ! system ?. cron ?. casparCGRestart ?. enabled ) return
87+ async function restartCasparCG ( systemSettings : ICoreSystemSettings | undefined , previousLastNightlyCronjob : number ) {
88+ if ( ! systemSettings ?. cron ?. casparCGRestart ?. enabled ) return
8689
8790 let shouldRetryAttempt = false
8891 const ps : Array < Promise < any > > = [ ]
@@ -176,10 +179,10 @@ async function restartCasparCG(system: ICoreSystem | undefined, previousLastNigh
176179 }
177180}
178181
179- async function storeSnapshots ( system : ICoreSystem | undefined ) {
180- if ( system ?. cron ?. storeRundownSnapshots ?. enabled ) {
181- const filter = system . cron . storeRundownSnapshots . rundownNames ?. length
182- ? { name : { $in : system . cron . storeRundownSnapshots . rundownNames } }
182+ async function storeSnapshots ( systemSettings : ICoreSystemSettings | undefined ) {
183+ if ( systemSettings ?. cron ?. storeRundownSnapshots ?. enabled ) {
184+ const filter = systemSettings . cron . storeRundownSnapshots . rundownNames ?. length
185+ ? { name : { $in : systemSettings . cron . storeRundownSnapshots . rundownNames } }
183186 : { }
184187
185188 const playlists = await RundownPlaylists . findFetchAsync ( filter )
0 commit comments