Check for missing directories
This commit is contained in:
parent
f3dcd5acbc
commit
e62832fde6
1 changed files with 113 additions and 90 deletions
23
src/app.rs
23
src/app.rs
|
|
@ -113,7 +113,30 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn ensure_watson_directories() -> anyhow::Result<()> {
|
||||||
|
// Create watson config directory if it doesn't exist
|
||||||
|
let watson_dir = dirs::config_dir()
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("Could not find config directory"))?
|
||||||
|
.join("watson");
|
||||||
|
|
||||||
|
if !watson_dir.exists() {
|
||||||
|
std::fs::create_dir_all(&watson_dir)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure frames file exists
|
||||||
|
let frames_path = watson_dir.join("frames");
|
||||||
|
if !frames_path.exists() {
|
||||||
|
// Create an empty frames file (empty JSON array)
|
||||||
|
std::fs::write(&frames_path, "[]")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new() -> anyhow::Result<Self> {
|
pub fn new() -> anyhow::Result<Self> {
|
||||||
|
// Ensure watson directories and files exist
|
||||||
|
Self::ensure_watson_directories()?;
|
||||||
|
|
||||||
let config = Config::load()?;
|
let config = Config::load()?;
|
||||||
let mut state = AppState::load()?;
|
let mut state = AppState::load()?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue