From 2a40e1e9ec32ee3532557ce5a737cd8ff3945926 Mon Sep 17 00:00:00 2001 From: forkless Date: Tue, 9 Jun 2026 13:44:02 +0200 Subject: [PATCH] =?UTF-8?q?consistent=20=E2=9A=A0=20spacing,=20block=20Ent?= =?UTF-8?q?er=20on=20corrupt=20archives?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 714a798..561aace 100644 --- a/src/main.rs +++ b/src/main.rs @@ -776,7 +776,7 @@ fn action_recover_bak(terminal: &mut Terminal, app: &mut App) -> } else { "Single Player" }; - Some(("⚠ Mode change", format!("{from} → {to}"))) + Some(("⚠ Mode change", format!("{from} → {to}"))) } else { None } @@ -786,7 +786,7 @@ fn action_recover_bak(terminal: &mut Terminal, app: &mut App) -> let bak_name = chosen.display_name.as_deref().unwrap_or("(unnamed)"); match live_name { Some(live) if live != bak_name => { - Some(("⚠ Name change", format!("{live} → {bak_name}"))) + Some(("⚠ Name change", format!("{live} → {bak_name}"))) } _ => None, } @@ -828,7 +828,7 @@ fn action_recover_bak(terminal: &mut Terminal, app: &mut App) -> details.push((&**k, &**v)); } if !has_existing_backup(app) { - details.push(("⚠ No backup", "create a full backup first")); + details.push(("⚠ No backup", "create a full backup first")); } let accepted = confirm_modal(terminal, app, "Confirm Recovery", &details)?; @@ -937,7 +937,9 @@ fn action_restore_backup(terminal: &mut Terminal, app: &mut App) .iter() .map(|p| { let name = p.file_name().unwrap().to_string_lossy().to_string(); - if name.contains("pre_restore") { + if !ops::check_tar_gz_integrity(p) { + "⚠ Corrupted — file does not appear to be a valid backup archive".into() + } else if name.contains("pre_restore") { "Pre-restore snapshot — safety copy made before a restore".into() } else if name.contains("migrated") { "Migrated from old backup format — treated as a full backup".into() @@ -973,6 +975,17 @@ fn action_restore_backup(terminal: &mut Terminal, app: &mut App) let chosen = &backups[idx]; let name = chosen.file_name().unwrap().to_string_lossy().to_string(); + // Block restore on corrupt archives + if !ops::check_tar_gz_integrity(chosen) { + ok_dialog(terminal, app, "Corrupt Backup", + "This backup archive appears to be corrupt or\n\ + incomplete and cannot be restored.\n\ + \n\ + Create a new full backup to replace it." + )?; + continue; + } + let mut restore_details = vec![("Backup", name.as_str())]; if !has_existing_backup(app) { restore_details.push(("⚠ No backup", "create a full backup first"));