mirror of
https://github.com/edu4rdshl/Strata.git
synced 2026-07-17 23:24:46 +00:00
fix: panic with clear message if XDG data dir is unavailable
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>
This commit is contained in:
parent
eb64476a2a
commit
8d681a16fd
1 changed files with 4 additions and 1 deletions
|
|
@ -8,7 +8,10 @@ pub struct Config {
|
|||
impl Config {
|
||||
pub fn new() -> Self {
|
||||
let data_dir = dirs::data_dir()
|
||||
.unwrap_or_else(|| PathBuf::from("."))
|
||||
.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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue