diff --git a/src/config.rs b/src/config.rs index 085046d..b751ac5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -55,6 +55,11 @@ pub fn backups_config_dir() -> PathBuf { p } +/// Ensure a directory exists, creating all parents as needed. +pub fn ensure_dir(path: PathBuf) { + let _ = std::fs::create_dir_all(&path); +} + /// Return the directory containing the running executable. pub fn exe_dir() -> PathBuf { std::env::current_exe() diff --git a/src/main.rs b/src/main.rs index c9418ca..4027be0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -156,6 +156,10 @@ fn run_app(terminal: &mut Terminal) -> Result<()> { result in incomplete, corrupt, or overwritten save files.", )?; + // Scaffold backup directory structure + crate::config::ensure_dir(crate::config::backups_saves_dir()); + crate::config::ensure_dir(crate::config::backups_config_dir()); + // Migrate old transaction.log into logs/ directory if guard::migrate_old_log() { guard::log_action("MIGRATE", "old transaction.log moved to logs/", "OK", &app.log_path)?;