fix: inconsistent data folder path
This commit is contained in:
parent
dc4de43516
commit
f1c9a5c1b2
@ -93,7 +93,7 @@ pub fn get_jan_data_folder_path<R: Runtime>(app_handle: tauri::AppHandle<R>) ->
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_configuration_file_path<R: Runtime>(app_handle: tauri::AppHandle<R>) -> PathBuf {
|
pub fn get_configuration_file_path<R: Runtime>(app_handle: tauri::AppHandle<R>) -> PathBuf {
|
||||||
let app_path = app_handle.path().app_data_dir().unwrap_or_else(|err| {
|
let app_path = std::fs::canonicalize(app_handle.path().app_data_dir().unwrap_or_else(|err| {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Failed to get app data directory: {}. Using home directory instead.",
|
"Failed to get app data directory: {}. Using home directory instead.",
|
||||||
err
|
err
|
||||||
@ -107,7 +107,7 @@ pub fn get_configuration_file_path<R: Runtime>(app_handle: tauri::AppHandle<R>)
|
|||||||
.expect("Failed to determine the home directory");
|
.expect("Failed to determine the home directory");
|
||||||
|
|
||||||
PathBuf::from(home_dir)
|
PathBuf::from(home_dir)
|
||||||
});
|
})).unwrap();
|
||||||
|
|
||||||
let package_name = env!("CARGO_PKG_NAME");
|
let package_name = env!("CARGO_PKG_NAME");
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@ -138,13 +138,15 @@ pub fn get_configuration_file_path<R: Runtime>(app_handle: tauri::AppHandle<R>)
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn default_data_folder_path<R: Runtime>(app_handle: tauri::AppHandle<R>) -> String {
|
pub fn default_data_folder_path<R: Runtime>(app_handle: tauri::AppHandle<R>) -> String {
|
||||||
let mut path = app_handle.path().data_dir().unwrap();
|
let mut path = app_handle.path().app_data_dir().unwrap();
|
||||||
|
|
||||||
let app_name = std::env::var("APP_NAME")
|
let app_name = std::env::var("APP_NAME")
|
||||||
.unwrap_or_else(|_| app_handle.config().product_name.clone().unwrap());
|
.unwrap_or_else(|_| app_handle.config().product_name.clone().unwrap());
|
||||||
path.push(app_name);
|
path.push(app_name);
|
||||||
path.push("data");
|
path.push("data");
|
||||||
|
|
||||||
|
path = std::fs::canonicalize(path).unwrap();
|
||||||
|
|
||||||
let mut path_str = path.to_str().unwrap().to_string();
|
let mut path_str = path.to_str().unwrap().to_string();
|
||||||
|
|
||||||
if let Some(stripped) = path.to_str().unwrap().to_string().strip_suffix(".ai.app") {
|
if let Some(stripped) = path.to_str().unwrap().to_string().strip_suffix(".ai.app") {
|
||||||
@ -152,6 +154,7 @@ pub fn default_data_folder_path<R: Runtime>(app_handle: tauri::AppHandle<R>) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
path_str
|
path_str
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user