Check for missing directories

This commit is contained in:
Ian Keane 2025-12-01 15:09:08 -05:00
parent f3dcd5acbc
commit e62832fde6

View file

@ -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> {
// Ensure watson directories and files exist
Self::ensure_watson_directories()?;
let config = Config::load()?;
let mut state = AppState::load()?;