diff options
| author | pml68 <contact@pml68.dev> | 2025-06-13 00:27:15 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-06-13 00:27:15 +0200 |
| commit | 0531f53a594f87faa7557d8a7cc049a807be6289 (patch) | |
| tree | c0ef5f915f4589d34263bd14fb3ff571d53332a1 /src | |
| parent | chore: extract `iced_drop` into separate repo (`pml68/iced_drop`) (diff) | |
| download | iced-builder-0531f53a594f87faa7557d8a7cc049a807be6289.tar.gz | |
feat: create config file on startup if it doesn't exist
Diffstat (limited to '')
| -rw-r--r-- | src/config.rs | 4 | ||||
| -rw-r--r-- | src/error.rs | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs index 369a505..8db16bb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -67,6 +67,10 @@ impl Config { let path = Self::config_file_path(); if !path.try_exists()? { + let _ = fs::File::create(path) + .await + .expect("expected permissions to create config file"); + return Err(Error::ConfigMissing); } diff --git a/src/error.rs b/src/error.rs index c8405f4..a65fb54 100644 --- a/src/error.rs +++ b/src/error.rs @@ -8,7 +8,7 @@ use thiserror::Error; #[error(transparent)] pub enum Error { IO(Arc<io::Error>), - #[error("Config does not exist")] + #[error("Config file does not exist, so an empty one was created")] ConfigMissing, #[error("JSON parsing error: {0}")] SerdeJSON(Arc<serde_json::Error>), |
