/** * Pure auto-update scheduling policy for yt-dlp. Kept free of any electron / * node-runtime dependency (like buildArgs.ts) so the throttle can be unit-tested * without spinning up Electron. ytdlp.ts imports these to drive the real check. */ /** Once-a-day throttle for the startup auto-update check. */ export const AUTO_UPDATE_INTERVAL_MS = 24 * 60 * 60 * 1000 /** * Whether a background yt-dlp update check should run now: only when auto-update * is enabled AND at least one interval has elapsed since the last check. A * zero/absent lastCheck means "never checked" → run. `now` and the interval are * passed in so the decision is a pure function of its inputs. */ export function shouldAutoCheckYtdlp( enabled: boolean, lastCheck: number, now: number, intervalMs: number = AUTO_UPDATE_INTERVAL_MS ): boolean { if (!enabled) return false if (!lastCheck) return true return now - lastCheck >= intervalMs }