scaffold backup dirs at startup, ensure_dir helper

This commit is contained in:
2026-06-03 01:38:25 +02:00
parent dffd8d2856
commit cd0a3dae00
2 changed files with 9 additions and 0 deletions
+5
View File
@@ -55,6 +55,11 @@ pub fn backups_config_dir() -> PathBuf {
p 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. /// Return the directory containing the running executable.
pub fn exe_dir() -> PathBuf { pub fn exe_dir() -> PathBuf {
std::env::current_exe() std::env::current_exe()
+4
View File
@@ -156,6 +156,10 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>) -> Result<()> {
result in incomplete, corrupt, or overwritten save files.", 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 // Migrate old transaction.log into logs/ directory
if guard::migrate_old_log() { if guard::migrate_old_log() {
guard::log_action("MIGRATE", "old transaction.log moved to logs/", "OK", &app.log_path)?; guard::log_action("MIGRATE", "old transaction.log moved to logs/", "OK", &app.log_path)?;