fix(media): don't cache whisper binary detection failure

Only cache successful whisper binary lookups. When whisper is not found,
leave the cache empty so subsequent calls re-check PATH. This allows
the app to detect a newly installed whisper without requiring a restart.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Naiyuan Qing 2026-02-09 18:10:23 +08:00
parent c27f4e66b5
commit 1bd25c5aec

View file

@ -18,8 +18,8 @@ import { execFile, execFileSync } from "node:child_process";
import { tmpdir } from "node:os";
import { credentialManager } from "../agent/credentials.js";
/** Cached path to local whisper binary, or false if not found */
let cachedWhisperBin: string | false | undefined;
/** Cached path to local whisper binary (only caches success; misses re-check each time) */
let cachedWhisperBin: string | undefined;
/** Find local whisper binary in PATH */
function findWhisperBin(): string | false {
@ -35,7 +35,7 @@ function findWhisperBin(): string | false {
}
}
cachedWhisperBin = false;
// Don't cache failure — whisper may be installed while the process is running
return false;
}