fix(main): R9 — guard the yt-dlp update throttle against a backward clock
shouldAutoCheckYtdlp compared (now - lastCheck) >= interval; a backward system- clock correction leaves lastCheck in the future so the difference is negative and the daily check never comes due again. Treat a future lastCheck as skewed and run the check. The renderer scheduled-item promoter is inherently fire-once (promotion flips the item out of 'saved'), so it can't double-fire on a backward jump — a forward jump firing early is documented and accepted as minor. Unit-tested. typecheck + 263 tests + eslint + prettier green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -31,4 +31,11 @@ describe('shouldAutoCheckYtdlp', () => {
|
||||
expect(shouldAutoCheckYtdlp(true, NOW - 30 * 60_000, NOW, hour)).toBe(false)
|
||||
expect(shouldAutoCheckYtdlp(true, NOW - hour, NOW, hour)).toBe(true)
|
||||
})
|
||||
|
||||
it('checks when the clock ran backward (lastCheck is in the future, R9)', () => {
|
||||
// A backward clock correction leaves lastCheck > now → (now - lastCheck) is
|
||||
// negative; without the guard the check would be skipped forever.
|
||||
expect(shouldAutoCheckYtdlp(true, NOW + AUTO_UPDATE_INTERVAL_MS, NOW)).toBe(true)
|
||||
expect(shouldAutoCheckYtdlp(true, NOW + 1, NOW)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user