mirror of
https://github.com/forkless/NotAlterra.git
synced 2026-08-18 17:22:32 +02:00
Show file counts for all backup/restore/delete operations
This commit is contained in:
+5
-4
@@ -689,8 +689,8 @@ fn action_restore_backup<B: Backend>(terminal: &mut Terminal<B>, app: &mut App)
|
||||
if accepted {
|
||||
guard::log_action("AUTO_BAK", &format!("pre-restore → {}", save_folder.display()), "OK", &app.log_path)?;
|
||||
match ops::restore_full_backup(chosen, &save_folder, &backup_root) {
|
||||
Ok(()) => {
|
||||
app.set_status("Restore complete. Previous files preserved.", tui::StatusStyle::Success);
|
||||
Ok(n) => {
|
||||
app.set_status(&format!("{n} save files restored."), tui::StatusStyle::Success);
|
||||
guard::log_action("RESTORE", &format!("{} → {}", name, save_folder.display()), "OK", &app.log_path)?;
|
||||
}
|
||||
Err(e) => {
|
||||
@@ -839,9 +839,10 @@ fn ini_restore_action<B: Backend>(
|
||||
|
||||
guard::log_action("AUTO_BAK", &format!("ini pre-restore → {}", config_path.display()), "OK", &app.log_path)?;
|
||||
match ops::restore_ini_files(chosen, config_path, backup_root) {
|
||||
Ok(()) => {
|
||||
Ok(n) => {
|
||||
guard::log_action("CONFIG_RESTORE", &chosen.display().to_string(), "OK", &app.log_path)?;
|
||||
ok_dialog(terminal, app, ".ini Restore Complete", ".ini files restored.")?;
|
||||
let msg = format!("{n} .ini file(s) restored.");
|
||||
ok_dialog(terminal, app, ".ini Restore Complete", &msg)?;
|
||||
}
|
||||
Err(e) => {
|
||||
ok_dialog(terminal, app, ".ini Restore Failed", &format!("{e}"))?;
|
||||
|
||||
+9
-5
@@ -128,7 +128,7 @@ pub fn restore_full_backup(
|
||||
backup_dir: &Path,
|
||||
save_folder: &Path,
|
||||
backup_root: &Path,
|
||||
) -> Result<()> {
|
||||
) -> Result<usize> {
|
||||
// Pre-restore safety backup
|
||||
let ts = Local::now().format("%Y-%m-%d_%H%M%S");
|
||||
let pre_restore = backup_root.join(format!("pre_restore_{ts}"));
|
||||
@@ -141,9 +141,11 @@ pub fn restore_full_backup(
|
||||
}
|
||||
|
||||
// Overwrite save folder with backup
|
||||
copy_save_files(backup_dir, save_folder, &mut dummy, &mut dummy_size)?;
|
||||
let mut count = 0usize;
|
||||
let mut _sz = 0u64;
|
||||
copy_save_files(backup_dir, save_folder, &mut count, &mut _sz)?;
|
||||
|
||||
Ok(())
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
// ── .ini management ────────────────────────────────────────────────────────
|
||||
@@ -197,7 +199,7 @@ pub fn restore_ini_files(
|
||||
backup_dir: &Path,
|
||||
config_path: &Path,
|
||||
backup_root: &Path,
|
||||
) -> Result<()> {
|
||||
) -> Result<usize> {
|
||||
// Pre-restore safety
|
||||
let ts = Local::now().format("%Y-%m-%d_%H%M%S");
|
||||
let pre_restore = backup_root.join(format!("ini_pre_restore_{ts}"));
|
||||
@@ -214,12 +216,14 @@ pub fn restore_ini_files(
|
||||
}
|
||||
|
||||
// Copy all files from backup → config_path
|
||||
let mut count = 0usize;
|
||||
for entry in fs::read_dir(backup_dir)? {
|
||||
let entry = entry?;
|
||||
fs::copy(entry.path(), config_path.join(entry.file_name()))?;
|
||||
count += 1;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
/// Delete all .ini files from the Config\Windows folder.
|
||||
|
||||
Reference in New Issue
Block a user