mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-12 20:47:22 +00:00
feat: enhance locations and download categorization
- Fix system proxy fetching logic in download queue - Expand recognized file formats across Windows, Mac, and Linux - Automatically assign matching category folder for new downloads - Add backend command to instantly create category directories on bulk base path selection
This commit is contained in:
@@ -678,6 +678,9 @@ async fn start_download(
|
||||
options.insert("all-proxy".to_string(), serde_json::json!(prox));
|
||||
} else {
|
||||
options.insert("all-proxy".to_string(), serde_json::json!(""));
|
||||
options.insert("http-proxy".to_string(), serde_json::json!(""));
|
||||
options.insert("https-proxy".to_string(), serde_json::json!(""));
|
||||
options.insert("no-proxy".to_string(), serde_json::json!("*"));
|
||||
}
|
||||
if let Some(cook) = cookies {
|
||||
options.insert("header".to_string(), serde_json::json!(format!("Cookie: {}", cook)));
|
||||
@@ -1527,7 +1530,8 @@ pub fn run() {
|
||||
check_file_exists, delete_file, toggle_tray_icon, set_extension_pairing_token,
|
||||
set_extension_frontend_ready, set_concurrent_limit, set_global_speed_limit, remove_download,
|
||||
parity::get_system_proxy, parity::get_file_category, parity::check_for_updates, parity::is_supported_media,
|
||||
db_save_settings, db_load_settings, db_get_all_downloads, db_save_download, db_delete_download, db_get_all_queues, db_save_queue, db_delete_queue
|
||||
db_save_settings, db_load_settings, db_get_all_downloads, db_save_download, db_delete_download, db_get_all_queues, db_save_queue, db_delete_queue,
|
||||
parity::create_category_directories
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
+27
-5
@@ -26,11 +26,12 @@ pub fn get_file_category(filename: String) -> DownloadCategory {
|
||||
.map(|s| s.to_lowercase())
|
||||
.unwrap_or_default();
|
||||
|
||||
let music_exts = ["aac", "aif", "aiff", "alac", "amr", "ape", "au", "caf", "flac", "m4a", "m4b", "mid", "midi", "mp3", "oga", "ogg", "opus", "ra", "wav", "weba", "wma"];
|
||||
let movie_exts = ["3g2", "3gp", "avi", "divx", "f4v", "flv", "m2ts", "m4v", "mkv", "mov", "mp4", "mpeg", "mpg", "mts", "ogm", "ogv", "rm", "rmvb", "ts", "vob", "webm", "wmv"];
|
||||
let compressed_exts = ["7z", "ace", "alz", "apk", "appx", "ar", "arc", "arj", "bz", "bz2", "cab", "cpio", "deb", "dmg", "gz", "gzip", "iso", "jar", "lha", "lzh", "lz", "lz4", "lzip", "lzma", "pak", "pkg", "rar", "rpm", "sit", "sitx", "tar", "tbz", "tbz2", "tgz", "tlz", "txz", "war", "whl", "xar", "xz", "z", "zip", "zipx", "zst"];
|
||||
let picture_exts = ["ai", "apng", "avif", "bmp", "cr2", "cr3", "dng", "emf", "eps", "gif", "heic", "heif", "ico", "indd", "jfif", "jpeg", "jpg", "jxl", "nef", "orf", "pbm", "pgm", "png", "pnm", "ppm", "psd", "raw", "rw2", "svg", "tga", "tif", "tiff", "webp", "wmf"];
|
||||
let document_exts = ["azw", "azw3", "csv", "djvu", "doc", "docm", "docx", "dot", "dotx", "epub", "fb2", "htm", "html", "ics", "key", "log", "md", "mobi", "pdf", "numbers", "odp", "ods", "odt", "pages", "pot", "potx", "pps", "ppsx", "ppt", "pptm", "pptx", "rtf", "tex", "txt", "vcf", "xls", "xlsm", "xlsx", "xml", "xps", "yaml", "yml"];
|
||||
let music_exts = ["mp3", "wav", "aac", "flac", "ogg", "m4a", "wma", "alac", "ape", "mid", "midi"];
|
||||
let movie_exts = ["mp4", "mkv", "avi", "mov", "wmv", "flv", "webm", "m4v", "mpeg", "mpg", "3gp", "ts", "vob"];
|
||||
let compressed_exts = ["zip", "rar", "7z", "tar", "gz", "xz", "bz2", "lz", "lzma", "zst", "iso", "cab", "tgz", "tbz", "z", "sit", "sitx"];
|
||||
let picture_exts = ["jpg", "jpeg", "png", "gif", "webp", "bmp", "tiff", "svg", "ico", "heic", "raw", "psd", "ai"];
|
||||
let document_exts = ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "rtf", "csv", "md", "epub", "mobi", "azw3"];
|
||||
let app_exts = ["exe", "msi", "bat", "cmd", "app", "dmg", "pkg", "apk", "appx", "deb", "rpm", "appimage", "run", "sh", "bin", "jar"];
|
||||
|
||||
if music_exts.contains(&ext.as_str()) {
|
||||
DownloadCategory::Musics
|
||||
@@ -42,6 +43,8 @@ pub fn get_file_category(filename: String) -> DownloadCategory {
|
||||
DownloadCategory::Pictures
|
||||
} else if document_exts.contains(&ext.as_str()) {
|
||||
DownloadCategory::Documents
|
||||
} else if app_exts.contains(&ext.as_str()) {
|
||||
DownloadCategory::Applications
|
||||
} else {
|
||||
DownloadCategory::Other
|
||||
}
|
||||
@@ -137,6 +140,25 @@ fn cmp_versions(a: &str, b: &str) -> std::cmp::Ordering {
|
||||
a_ver.cmp(&b_ver)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn create_category_directories(app_handle: tauri::AppHandle, paths: Vec<String>) -> Result<(), String> {
|
||||
use tauri::Manager;
|
||||
for path in paths {
|
||||
let mut expanded = std::path::PathBuf::from(&path);
|
||||
if path.starts_with("~/") {
|
||||
if let Ok(home) = app_handle.path().home_dir() {
|
||||
expanded = home.join(&path[2..]);
|
||||
}
|
||||
}
|
||||
if !expanded.exists() {
|
||||
if let Err(e) = tokio::fs::create_dir_all(&expanded).await {
|
||||
eprintln!("Failed to create directory {}: {}", path, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn is_supported_media(url: String) -> bool {
|
||||
if let Ok(parsed_url) = reqwest::Url::parse(&url) {
|
||||
|
||||
Reference in New Issue
Block a user