Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

refactor: improve ffmpeg availability check with caching mechanism

Tonhoa3ad5006712a
diff --git a/src-tauri/src/core/ffmpeg.rs b/src-tauri/src/core/ffmpeg.rs
index 4fede94c..71b30e6e 100644
--- a/src-tauri/src/core/ffmpeg.rs
+++ b/src-tauri/src/core/ffmpeg.rs
@@ -7,7 +7,15 @@ use tokio::sync::mpsc;
use tokio_util::sync::CancellationToken;
pub async fn is_ffmpeg_available() -> bool {
- crate::core::dependencies::find_tool("ffmpeg").await.is_some()
+ use tokio::sync::OnceCell;
+ static CACHED: OnceCell<bool> = OnceCell::const_new();
+ *CACHED
+ .get_or_init(|| async {
+ crate::core::dependencies::find_tool("ffmpeg")
+ .await
+ .is_some()
+ })
+ .await
}
pub async fn mux_video_audio(video: &Path, audio: &Path, output: &Path) -> anyhow::Result<()> {