refactor(site): one ffmpeg gate instead of a probe plus a log call

ffmpeg_available() and log_once_ffmpeg_missing() only ever appeared together (both encoders, three lines each: check, log, return), and calling one without the other was a bug in waiting — a probe that never logged, or a log that never gated. ffmpeg_missing() is the single gate: false when the binary is there, otherwise log once per process and say yes. Both call sites shrink to one condition.
This commit is contained in:
2026-09-24 04:37:52 +08:00
parent e64b48a453
commit a3d03cf30f
3 changed files with 10 additions and 9 deletions
+8 -5
View File
@@ -313,14 +313,17 @@ static FFMPEG_AVAILABLE: LazyLock<bool> = LazyLock::new(|| {
static FFMPEG_MISSING_LOGGED: AtomicBool = AtomicBool::new(false);
pub(crate) fn ffmpeg_available() -> bool {
*FFMPEG_AVAILABLE
}
pub(crate) fn log_once_ffmpeg_missing() {
/// Whether the encode step must be skipped: no ffmpeg on PATH, logged once
/// per process. The one gate both encoders check — the probe and the
/// log-once used to be two functions that only ever appeared together.
pub(crate) fn ffmpeg_missing() -> bool {
if *FFMPEG_AVAILABLE {
return false;
}
if !FFMPEG_MISSING_LOGGED.swap(true, Ordering::Relaxed) {
log::warn!("ffmpeg not found; ugoira and bsky video posts stay unsupported");
}
true
}
/// Site adapter: one impl per supported site (twitter / bsky / misskey /