fix: resolve P3 audit findings

This commit is contained in:
NimBold
2026-06-15 14:24:34 +03:30
parent 789a8161b2
commit 1b04860c94
9 changed files with 27 additions and 134 deletions
+2 -1
View File
@@ -52,6 +52,7 @@ tokio-tungstenite = "0.29.0"
futures-util = { version = "0.3.32", features = ["sink"] }
rusqlite = { version = "0.40.1", features = ["bundled"] }
chrono = "0.4.38"
url = "2"
[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.25"
objc = "0.2.7"
url = "2"
+2 -2
View File
@@ -1,6 +1,6 @@
use rusqlite::{Connection, Result, params};
use tokio::sync::Mutex;
use std::path::PathBuf;
use tauri::Manager;
pub struct DbState {
@@ -8,7 +8,7 @@ pub struct DbState {
}
pub fn init_db(app_handle: &tauri::AppHandle) -> Result<Connection> {
let app_dir = app_handle.path().app_data_dir().unwrap_or_else(|_| PathBuf::from("."));
let app_dir = app_handle.path().app_data_dir().expect("Cannot get app data dir");
if !app_dir.exists() {
let _ = std::fs::create_dir_all(&app_dir);
}
+5 -10
View File
@@ -81,16 +81,11 @@ pub async fn start_server(
.layer(cors)
.with_state(state);
let mut listener = None;
for port in EXTENSION_SERVER_PORT..=(EXTENSION_SERVER_PORT + 10) {
if let Ok(l) = tokio::net::TcpListener::bind(("127.0.0.1", port)).await {
listener = Some((l, port));
break;
}
}
let (listener, bound_port) = listener.ok_or_else(|| "Failed to bind extension server to any port".to_string())?;
println!("Browser extension server bound to 127.0.0.1:{}", bound_port);
let listener = tokio::net::TcpListener::bind(("127.0.0.1", EXTENSION_SERVER_PORT))
.await
.map_err(|e| format!("Failed to bind extension server to port {}: {}", EXTENSION_SERVER_PORT, e))?;
println!("Browser extension server bound to 127.0.0.1:{}", EXTENSION_SERVER_PORT);
axum::serve(listener, app)
.await
+9 -4
View File
@@ -837,9 +837,13 @@ pub(crate) async fn start_media_download_internal(
let stdout = child.stdout.take().ok_or("Failed to capture stdout")?;
// yt-dlp parsing regex
let pct_re = Regex::new(r"\[download\]\s+(\d+(?:\.\d+)?)%").unwrap();
let spd_re = Regex::new(r"at\s+([^\s]+)").unwrap();
let eta_re = Regex::new(r"ETA\s+([^\s]+)").unwrap();
static PCT_RE: std::sync::OnceLock<Regex> = std::sync::OnceLock::new();
static SPD_RE: std::sync::OnceLock<Regex> = std::sync::OnceLock::new();
static ETA_RE: std::sync::OnceLock<Regex> = std::sync::OnceLock::new();
let pct_re = PCT_RE.get_or_init(|| Regex::new(r"\[download\]\s+(\d+(?:\.\d+)?)%").unwrap());
let spd_re = SPD_RE.get_or_init(|| Regex::new(r"at\s+([^\s]+)").unwrap());
let eta_re = ETA_RE.get_or_init(|| Regex::new(r"ETA\s+([^\s]+)").unwrap());
let _keep_alive = config_path;
let mut reader = BufReader::new(stdout).lines();
@@ -1195,7 +1199,8 @@ fn toggle_tray_icon(app_handle: tauri::AppHandle, show: bool) -> Result<(), Stri
let show_i = MenuItem::with_id(&app_handle, "show", "Show Firelink", true, None::<&str>).map_err(|e| e.to_string())?;
let menu = Menu::with_items(&app_handle, &[&show_i, &quit_i]).map_err(|e| e.to_string())?;
let tray_icon = tauri::image::Image::from_bytes(include_bytes!("../icons/trayTemplate.png")).unwrap();
let tray_icon = tauri::image::Image::from_bytes(include_bytes!("../icons/trayTemplate.png"))
.map_err(|e| e.to_string())?;
let _tray = TrayIconBuilder::with_id("main")
.icon(tray_icon)
.icon_as_template(true)
+1 -1
View File
@@ -6,7 +6,7 @@ use std::time::Duration;
pub fn spawn_scheduler(app_handle: tauri::AppHandle) {
tauri::async_runtime::spawn(async move {
let mut interval = tokio::time::interval(Duration::from_secs(10));
let mut interval = tokio::time::interval(Duration::from_secs(1));
loop {
interval.tick().await;