1 Commits
Author SHA1 Message Date
qwsdcvghyu89 ad729133a6 Restore project file on cancel event
Adds a handler for Console.CancelKeyPress to restore the project file from backup if the process is interrupted, ensuring changes are not left in an inconsistent state.
2025-09-27 15:56:20 +10:00
+5
View File
@@ -124,6 +124,11 @@ public static class Program {
try { try {
projectFile.Backup(); projectFile.Backup();
Console.CancelKeyPress += (sender, eventArgs) => {
projectFile.Restore();
AnsiConsole.MarkupLine("[yellow]Restored project file from backup.[/]");
};
if (Verbose) if (Verbose)
AnsiConsole.WriteLine( AnsiConsole.WriteLine(
$"Created project file backup at {projectFile.GetDefaultBackupLocation()}"); $"Created project file backup at {projectFile.GetDefaultBackupLocation()}");