From 30ff2f88fc21c833d883c320b61b981ace949513 Mon Sep 17 00:00:00 2001 From: Christian Benincasa Date: Tue, 14 Apr 2026 17:08:18 -0400 Subject: [PATCH] fix: guide generation after initial server start should always happen --- server/src/services/TvGuideService.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/services/TvGuideService.ts b/server/src/services/TvGuideService.ts index a69f2271..e17b45ef 100644 --- a/server/src/services/TvGuideService.ts +++ b/server/src/services/TvGuideService.ts @@ -427,13 +427,17 @@ export class TVGuideService { lock.runExclusive(async () => { this.logger.info('Building guide info for channel %s', channelId); devAssert(!isEmpty(this.channelsById)); - const now = startTime; + // Use real wall-clock time for cache staleness checks so that + // a backdated startTime (e.g. startOf('hour')) doesn't prevent + // rebuilds when the lineup changes within the same period. + const now = +dayjs(); const lastUpdateTime = this.lastUpdateTime[channelId] ?? 0; const currentUpdateTime = this.currentUpdateTime[channelId] ?? -1; if (force || (lastUpdateTime < now && currentUpdateTime === -1)) { - this.currentUpdateTime[channelId] = now; - this.currentEndTime[channelId] = now + guideDuration.asMilliseconds(); + this.currentUpdateTime[channelId] = startTime; + this.currentEndTime[channelId] = + startTime + guideDuration.asMilliseconds(); await this.buildChannelGuideWithRetries(channelId, writeXmlTv); }