fix: migrate old config_* ini backups to tar.gz

This commit is contained in:
2026-06-03 02:03:01 +02:00
parent cd0a3dae00
commit cf2b31de33
2 changed files with 39 additions and 22 deletions
+8 -1
View File
@@ -4,6 +4,13 @@ Cross-platform terminal application. No admin permissions or network access req
Pre-compiled binaries — no installation, no dependencies. Just download,
extract, and run.
### What's new in v0.4.1
• Log migration — existing `transaction.log` is moved into `logs/` on first launch
• Backup directory structure scaffolded at startup (`backups/saves/`, `backups/config/`, `logs/`)
`ensure_dir()` helper for consistent directory creation
• All migration paths integrated into startup (config.ini, backups, log)
### What's new in v0.4.0
• tar.gz backup format — one archive per backup event, standard `tar -xzf` recovers data without the tool
@@ -15,4 +22,4 @@ extract, and run.
• 6 migration tests, full round-trip tar.gz integration tests
`tar` + `flate2` dependencies added (pure Rust, ~150KB increase)
_Builds: Linux (amd64) • Windows x64_
Builds: Linux (amd64) • Windows x64
+17 -7
View File
@@ -395,15 +395,12 @@ fn migrate_backups_from(old_root: PathBuf) -> Result<usize> {
continue;
}
let dir_name = entry.file_name().to_string_lossy().to_string();
if !dir_name.starts_with("notalterra_copy_") {
continue;
}
// Check if this directory contains save files
if dir_name.starts_with("notalterra_copy_") {
// Migrate old save backups → backups/saves/
let has_saves = fs::read_dir(&path)
.map(|e| e.flatten().any(|f| {
let fname = f.file_name();
let n = fname.to_string_lossy();
n.starts_with("savegame_")
f.file_name().to_string_lossy().starts_with("savegame_")
}))
.unwrap_or(false);
if !has_saves {
@@ -419,6 +416,19 @@ fn migrate_backups_from(old_root: PathBuf) -> Result<usize> {
eprintln!("migration warning: failed to archive {:?}: {}", path, e);
}
}
} else if dir_name.starts_with("config_") {
// Migrate old .ini backups → backups/config/
let backup_dir = crate::config::backups_config_dir();
match create_tar_gz(&path, &backup_dir, "", &format!("migrated_{dir_name}")) {
Ok((_count, _size, archive_path)) if archive_path.exists() => {
migrated += 1;
}
Ok(_) => {},
Err(e) => {
eprintln!("migration warning: failed to archive {:?}: {}", path, e);
}
}
}
}
}
Ok(migrated)