mirror of
https://github.com/edu4rdshl/Strata.git
synced 2026-07-17 23:24:46 +00:00
The previous fallback to PathBuf::from(".") silently placed the
database in whatever the current working directory was, making it
impossible to find later. Since the daemon cannot function without a
persistent database, failing fast with an actionable message is the
correct behavior.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
26 lines
631 B
Rust
26 lines
631 B
Rust
use std::path::PathBuf;
|
|
|
|
pub struct Config {
|
|
pub db_path: PathBuf,
|
|
pub max_history: usize,
|
|
}
|
|
|
|
impl Config {
|
|
pub fn new() -> Self {
|
|
let data_dir = dirs::data_dir()
|
|
.expect(
|
|
"Could not determine XDG data directory. \
|
|
Ensure $XDG_DATA_HOME or $HOME is set.",
|
|
)
|
|
.join("strata");
|
|
|
|
if let Err(e) = std::fs::create_dir_all(&data_dir) {
|
|
tracing::warn!("Could not create data dir {:?}: {}", data_dir, e);
|
|
}
|
|
|
|
Self {
|
|
db_path: data_dir.join("clipboard.db"),
|
|
max_history: 200,
|
|
}
|
|
}
|
|
}
|