bug fix 1

This commit is contained in:
Julian Freeman
2025-12-02 09:23:31 -04:00
parent a18065de93
commit c6d5f6679a
3 changed files with 48 additions and 13 deletions

View File

@@ -1,9 +1,10 @@
// filepath: src-tauri/src/commands.rs
use tauri::AppHandle;
use tauri::{AppHandle, Manager};
use crate::{ytdlp, downloader, storage};
use crate::downloader::DownloadOptions;
use crate::storage::{Settings, HistoryItem};
use uuid::Uuid;
use std::path::Path;
#[tauri::command]
pub async fn init_ytdlp(app: AppHandle) -> Result<bool, String> {
@@ -89,20 +90,28 @@ pub fn delete_history_item(app: AppHandle, id: String) -> Result<(), String> {
}
#[tauri::command]
pub fn open_in_explorer(path: String) -> Result<(), String> {
pub fn open_in_explorer(app: AppHandle, path: String) -> Result<(), String> {
let path_to_open = if Path::new(&path).exists() {
path
} else {
app.path().download_dir()
.map(|p| p.to_string_lossy().to_string())
.unwrap_or_else(|_| ".".to_string())
};
#[cfg(target_os = "windows")]
{
std::process::Command::new("explorer")
.arg(path)
.arg(path_to_open)
.spawn()
.map_err(|e| e.to_string())?;
}
#[cfg(target_os = "macos")]
{
std::process::Command::new("open")
.arg(path)
.arg(path_to_open)
.spawn()
.map_err(|e| e.to_string())?;
}
Ok(())
}
}