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.
This commit is contained in:
@@ -124,6 +124,11 @@ public static class Program {
|
||||
|
||||
try {
|
||||
projectFile.Backup();
|
||||
Console.CancelKeyPress += (sender, eventArgs) => {
|
||||
projectFile.Restore();
|
||||
AnsiConsole.MarkupLine("[yellow]Restored project file from backup.[/]");
|
||||
};
|
||||
|
||||
if (Verbose)
|
||||
AnsiConsole.WriteLine(
|
||||
$"Created project file backup at {projectFile.GetDefaultBackupLocation()}");
|
||||
|
||||
Reference in New Issue
Block a user