Skip to content

Commit

Permalink
fix: better error handling on checking + installing ffmpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
seleb committed May 16, 2023
1 parent b292216 commit 4aa07e7
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command

use ffmpeg_sidecar::{command::FfmpegCommand, paths::ffmpeg_path};
use std::{
path::Path,
process::{Command, Stdio},
};
use std::path::Path;
use tauri::Manager;

// create the error type that represents all errors possible in our program
Expand All @@ -31,17 +33,24 @@ impl serde::Serialize for Error {
}
}

#[tauri::command(async)]
fn is_ffmpeg_installed() -> bool {
ffmpeg_sidecar::command::ffmpeg_is_installed()
#[tauri::command]
async fn is_ffmpeg_installed() -> Result<bool, Error> {
match Command::new(ffmpeg_path())
.arg("-version")
.stderr(Stdio::null())
.stdout(Stdio::null())
.spawn()
{
Ok(_) => Ok(true),
Err(_) => Ok(false),
}
}

#[tauri::command(async)]
fn install_ffmpeg() -> Result<(), ()> {
if let Ok(()) = ffmpeg_sidecar::download::auto_download() {
Ok(())
} else {
Err(())
#[tauri::command]
async fn install_ffmpeg() -> Result<(), Error> {
match ffmpeg_sidecar::download::auto_download() {
Ok(_) => Ok(()),
Err(e) => Err(Error::from(e)),
}
}

Expand Down

0 comments on commit 4aa07e7

Please sign in to comment.