[update] improved configuration path handling in config.rs, fixed path-to-string conversion errors, and adjusted paths for renamed project and user-specific directories

This commit is contained in:
2025-08-06 13:27:54 +02:00
parent d90c618ee3
commit 300845c655

View File

@@ -63,27 +63,32 @@ impl AppSettings {
fn get_db_path() -> String {
if cfg!(debug_assertions) {
// Development: Use backend-rust directory
// TODO: Change later
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("owlynews.sqlite3");
path.to_str().unwrap().to_string()
path.to_str()
.ok_or_else(|| anyhow::anyhow!("Failed to convert path to string"))
.ok()
.expect("Failed to convert path to string")
.to_string()
} else {
// Production: Use standard Linux applications data directory
"/var/lib/owly-news-summariser/owlynews.sqlite3".to_string()
"/var/lib/owly-news/owlynews.sqlite3".to_string()
}
}
fn get_config_path() -> String {
if cfg!(debug_assertions) {
// Development: Use backend-rust directory
// TODO: Change later
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("config.toml");
path.to_str().unwrap().to_string()
path.to_str()
.ok_or_else(|| anyhow::anyhow!("Failed to convert path to string"))
.ok()
.expect("Failed to convert path to string")
.to_string()
} else {
// Production: Use standard Linux applications data directory
"$HOME/owly-news-summariser/config.toml".to_string()
let home = env::var("HOME").unwrap_or_else(|_| "/tmp".to_string());
format!("{}/.config/owly-news/config.toml", home)
}
}