diff --git a/src-tauri/src/lang.rs b/src-tauri/src/lang.rs index 665ac5a..04a4fc4 100644 --- a/src-tauri/src/lang.rs +++ b/src-tauri/src/lang.rs @@ -1,5 +1,5 @@ use crate::system_helpers::*; -use std::path::{Path, PathBuf}; +use std::path::{ Path, PathBuf }; #[tauri::command] pub async fn get_lang(window: tauri::Window, lang: String) -> String { @@ -27,7 +27,12 @@ pub async fn get_languages() -> std::collections::HashMap { for entry in lang_files { let entry = entry.unwrap(); let path = entry.path(); - let filename = path.file_name().unwrap().to_str().unwrap(); + let filename = path + .file_name() + .unwrap_or_else(|| panic!("Failed to get filename from path: {:?}", path)) + .to_str() + .unwrap_or_else(|| panic!("Failed to convert filename to string: {:?}", path)) + .to_string(); let content = match std::fs::read_to_string(&path) { Ok(x) => x, @@ -49,4 +54,4 @@ pub fn emit_lang_err(window: tauri::Window, msg: String) { res_hash.insert("error".to_string(), msg); window.emit("lang_error", &res_hash).unwrap(); -} +} \ No newline at end of file