From 252b4f97419b0143a9da8bb453541024aeeb117e Mon Sep 17 00:00:00 2001 From: sciencewhiz Date: Mon, 16 Dec 2024 20:29:25 -0800 Subject: [PATCH] Clean-up Choreo if previously installed --- .../ViewModels/InstallPageViewModel.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/WPILibInstaller-Avalonia/ViewModels/InstallPageViewModel.cs b/WPILibInstaller-Avalonia/ViewModels/InstallPageViewModel.cs index 7d24554..49a4ef2 100644 --- a/WPILibInstaller-Avalonia/ViewModels/InstallPageViewModel.cs +++ b/WPILibInstaller-Avalonia/ViewModels/InstallPageViewModel.cs @@ -164,6 +164,10 @@ private async Task InstallEverything(CancellationToken token) ProgressTotal = 88; TextTotal = "Creating Shortcuts"; await RunShortcutCreator(token); + if (token.IsCancellationRequested) break; + ProgressTotal = 99; + TextTotal = "Cleaning Up"; + await RunChoreoCleanup(); } while (false); } catch (OperationCanceledException) @@ -984,5 +988,26 @@ await Task.Run(() => }, token); } } + + private async Task RunChoreoCleanup() + { + if (Directory.Exists(Path.Combine(configurationProvider.InstallDirectory, "choreo"))) { + Text = "Clean up Choreo Directory"; + Progress = 25; + Directory.Delete(Path.Combine(configurationProvider.InstallDirectory, "choreo"), true); + + Text = "Clean up Choreo Scripts"; + Progress = 50; + File.Delete(Path.Combine(configurationProvider.InstallDirectory, "tools", "choreo.vbs")); + File.Delete(Path.Combine(configurationProvider.InstallDirectory, "tools", "choreo.sh")); + + Text = "Clean up Choreo Vendordeps"; + Progress = 75; + File.Delete(Path.Combine(configurationProvider.InstallDirectory, "vendordeps", "ChoreoLib2025Beta.json")); + } + + await Task.Yield(); + } + } }