mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(update): run periodic update check in daemon so hints actually fire (#76)
* fix(update): run periodic update check in daemon so hints actually fire The CLI spawned a detached thread to refresh ~/.bsk/update-check.json, but the process exits as soon as the command finishes, killing the thread before the fetch could complete — so the cache was never written and the new-version hint never showed. Move the periodic check into the daemon: a tokio task ticks every 30 minutes (down from 24h), refreshes the cache when missing/stale, and logs failures at warn/info into the daemon log. The CLI path is now read-only: it prints the hint only from a fresh cache and never spawns threads or touches the network. * fix(update): decouple daemon refresh window so checks truly run every 30min The refresh decision reused the 30min tick interval as its freshness window, and with is_fresh()'s inclusive bound a cache written just after tick N still counted as fresh at tick N+1 — so in steady state the daemon only refetched every other tick (~60min). Judge staleness against DAEMON_REFRESH_WINDOW (25min = 5/6 of the tick) instead: every 30min tick now finds the cache stale and really refreshes, while a daemon restarted with a younger-than-25min cache still skips its first tick. CLI hint freshness semantics (UPDATE_CHECK_INTERVAL = 30min) are unchanged.
This commit is contained in:
@@ -25,7 +25,7 @@ fn main() -> ExitCode {
|
||||
if !matches!(cli.command, Command::Daemon(_)) {
|
||||
init_cli_tracing(&cli.flags);
|
||||
}
|
||||
cli::update::maybe_spawn_background_check(&cli.flags, &cli.command);
|
||||
cli::update::print_update_hint_from_cache(&cli.flags, &cli.command);
|
||||
|
||||
let format = if cli.flags.json {
|
||||
Format::Json
|
||||
|
||||
Reference in New Issue
Block a user