Skip to content

PR: Sub Issue 9 - BackupConfig + Restore/CleanBackup#328

Merged
JusterZhu merged 1 commit into
masterfrom
feature/backup-config
May 24, 2026
Merged

PR: Sub Issue 9 - BackupConfig + Restore/CleanBackup#328
JusterZhu merged 1 commit into
masterfrom
feature/backup-config

Conversation

@JusterZhu
Copy link
Copy Markdown
Collaborator

Summary

Closes #327

Changes

  • \StorageManager.Restore()\ — bulk restore from backup directory
  • \StorageManager.CleanBackup()\ — auto-clean old backups (keep N versions)
  • \StorageManager.ListBackups()\ — query backup metadata
  • \BackupConfig\ — KeepVersions, BackupRoot, SkipDirectories, Enabled
  • \BackupInfo\ record — Version, Path, CreatedAt, SizeBytes

Build

✅ 0 errors

- StorageManager.Restore() — restore from backup to install path
- StorageManager.CleanBackup() — keep only N most recent backups
- StorageManager.ListBackups() — query backup metadata
- BackupConfig — version retention, skip dirs, enable/disable
- BackupInfo record — version, path, timestamp, size

Closes #327
Copilot AI review requested due to automatic review settings May 24, 2026 00:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds backup management capabilities to GeneralUpdate.Core by introducing backup metadata/config types and new StorageManager APIs for restoring from backups, listing backup versions, and cleaning up old backups (Sub Issue 9, closes #327).

Changes:

  • Added StorageManager.Restore() (bulk restore), CleanBackup() (keep N newest), and ListBackups() (metadata + size).
  • Introduced BackupConfig (Enabled/KeepVersions/BackupRoot/SkipDirectories).
  • Introduced BackupInfo record (Version/Path/CreatedAt/SizeBytes).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +286 to +288
/// <summary>Restore files from backup directory to install path.</summary>
public static void Restore(string backupDir, string installPath)
{
Comment on lines +301 to +314
/// <summary>Clean old backups, keeping only the N most recent versions.</summary>
public static void CleanBackup(string installPath, int keepVersions = 3)
{
var backupRoot = Path.Combine(installPath, "__backups");
if (!Directory.Exists(backupRoot)) return;

var dirs = Directory.GetDirectories(backupRoot)
.Select(d => new DirectoryInfo(d))
.OrderByDescending(d => d.CreationTime)
.Skip(keepVersions);

foreach (var dir in dirs)
dir.Delete(true);
}
Comment on lines +316 to +328
/// <summary>List backup versions with metadata.</summary>
public static IReadOnlyList<BackupInfo> ListBackups(string installPath)
{
var backupRoot = Path.Combine(installPath, "__backups");
if (!Directory.Exists(backupRoot)) return Array.Empty<BackupInfo>();

return Directory.GetDirectories(backupRoot)
.Select(d => new DirectoryInfo(d))
.Select(d => new BackupInfo(
d.Name, d.FullName, d.CreationTime,
d.GetFiles("*", SearchOption.AllDirectories).Sum(f => f.Length)))
.ToList();
}
Comment on lines +286 to +287
/// <summary>Restore files from backup directory to install path.</summary>
public static void Restore(string backupDir, string installPath)
@JusterZhu JusterZhu merged commit c57c8b1 into master May 24, 2026
1 check passed
@JusterZhu JusterZhu deleted the feature/backup-config branch May 24, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sub Issue 9: BackupConfig + StorageManager restore/clean

2 participants