diff --git a/StabilityMatrix/App.xaml.cs b/StabilityMatrix/App.xaml.cs index b3b2206f..d9168a04 100644 --- a/StabilityMatrix/App.xaml.cs +++ b/StabilityMatrix/App.xaml.cs @@ -5,8 +5,8 @@ using System.IO; using System.Linq; using System.Net; using System.Net.Http; -using System.Text.Json; using System.Text.Json.Serialization; +using System.Threading; using System.Threading.Tasks; using System.Windows; using AsyncAwaitBestPractices; @@ -148,11 +148,28 @@ namespace StabilityMatrix { if (AppDomain.CurrentDomain.BaseDirectory.EndsWith("Update\\")) { - File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StabilityMatrix.exe"), - Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "StabilityMatrix.exe"), true); - Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", - "StabilityMatrix.exe")); - Current.Shutdown(); + var delays = Backoff.DecorrelatedJitterBackoffV2( + TimeSpan.FromMilliseconds(150), retryCount: 3); + foreach (var dlay in delays) + { + try + { + File.Copy( + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, + "StabilityMatrix.exe"), + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", + "StabilityMatrix.exe"), true); + + Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", + "StabilityMatrix.exe")); + + Current.Shutdown(); + } + catch (Exception) + { + Thread.Sleep(dlay); + } + } return; } diff --git a/StabilityMatrix/DataDirectoryMigrationDialog.xaml.cs b/StabilityMatrix/DataDirectoryMigrationDialog.xaml.cs index ca5de5bb..34ef5952 100644 --- a/StabilityMatrix/DataDirectoryMigrationDialog.xaml.cs +++ b/StabilityMatrix/DataDirectoryMigrationDialog.xaml.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using System.Threading.Tasks; using System.Windows; using AsyncAwaitBestPractices; diff --git a/StabilityMatrix/DesignData/MockFirstLaunchSetupViewModel.cs b/StabilityMatrix/DesignData/MockFirstLaunchSetupViewModel.cs index daa0d1d4..b3829c7b 100644 --- a/StabilityMatrix/DesignData/MockFirstLaunchSetupViewModel.cs +++ b/StabilityMatrix/DesignData/MockFirstLaunchSetupViewModel.cs @@ -1,5 +1,4 @@ -using StabilityMatrix.Models; -using StabilityMatrix.Models.Progress; +using StabilityMatrix.Models.Progress; using StabilityMatrix.ViewModels; namespace StabilityMatrix.DesignData; diff --git a/StabilityMatrix/Helper/ArchiveHelper.cs b/StabilityMatrix/Helper/ArchiveHelper.cs index 538bc1d8..8c82d550 100644 --- a/StabilityMatrix/Helper/ArchiveHelper.cs +++ b/StabilityMatrix/Helper/ArchiveHelper.cs @@ -9,7 +9,6 @@ using System.Windows.Threading; using NLog; using SharpCompress.Common; using SharpCompress.Readers; -using StabilityMatrix.Models; using StabilityMatrix.Models.Progress; namespace StabilityMatrix.Helper; diff --git a/StabilityMatrix/Helper/EventManager.cs b/StabilityMatrix/Helper/EventManager.cs index 553ddcd2..45c77982 100644 --- a/StabilityMatrix/Helper/EventManager.cs +++ b/StabilityMatrix/Helper/EventManager.cs @@ -1,5 +1,4 @@ using System; -using StabilityMatrix.Models; using StabilityMatrix.Updater; namespace StabilityMatrix.Helper; diff --git a/StabilityMatrix/Helper/FileHash.cs b/StabilityMatrix/Helper/FileHash.cs index b6de3a7e..f59857c3 100644 --- a/StabilityMatrix/Helper/FileHash.cs +++ b/StabilityMatrix/Helper/FileHash.cs @@ -4,7 +4,6 @@ using System.IO; using System.Security.Cryptography; using System.Threading.Tasks; using Blake3; -using StabilityMatrix.Models; using StabilityMatrix.Models.Progress; namespace StabilityMatrix.Helper; diff --git a/StabilityMatrix/Helper/FileTransfers.cs b/StabilityMatrix/Helper/FileTransfers.cs index 129c9c41..1f63e93b 100644 --- a/StabilityMatrix/Helper/FileTransfers.cs +++ b/StabilityMatrix/Helper/FileTransfers.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; -using StabilityMatrix.Models; using StabilityMatrix.Models.Progress; namespace StabilityMatrix.Helper; diff --git a/StabilityMatrix/Helper/IPrerequisiteHelper.cs b/StabilityMatrix/Helper/IPrerequisiteHelper.cs index 7215e301..91cf5c4f 100644 --- a/StabilityMatrix/Helper/IPrerequisiteHelper.cs +++ b/StabilityMatrix/Helper/IPrerequisiteHelper.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Tasks; -using StabilityMatrix.Models; using StabilityMatrix.Models.Progress; namespace StabilityMatrix.Helper; diff --git a/StabilityMatrix/Helper/ModelFinder.cs b/StabilityMatrix/Helper/ModelFinder.cs index 26160f3e..8062dfd9 100644 --- a/StabilityMatrix/Helper/ModelFinder.cs +++ b/StabilityMatrix/Helper/ModelFinder.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using System.Threading.Tasks; using NLog; using Refit; diff --git a/StabilityMatrix/Helper/PrerequisiteHelper.cs b/StabilityMatrix/Helper/PrerequisiteHelper.cs index 4a28078c..174224a4 100644 --- a/StabilityMatrix/Helper/PrerequisiteHelper.cs +++ b/StabilityMatrix/Helper/PrerequisiteHelper.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Win32; using Octokit; -using StabilityMatrix.Models; using StabilityMatrix.Models.Progress; using StabilityMatrix.Python; using StabilityMatrix.Services; diff --git a/StabilityMatrix/Helper/SettingsManager.cs b/StabilityMatrix/Helper/SettingsManager.cs index 4f172515..6d9c5715 100644 --- a/StabilityMatrix/Helper/SettingsManager.cs +++ b/StabilityMatrix/Helper/SettingsManager.cs @@ -115,10 +115,13 @@ public class SettingsManager : ISettingsManager var homeDir = Path.Combine(appDataDir, "StabilityMatrix"); Directory.CreateDirectory(homeDir); var libraryJsonPath = Path.Combine(homeDir, "library.json"); - + var library = new LibrarySettings { LibraryPath = path }; var libraryJson = JsonSerializer.Serialize(library, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(libraryJsonPath, libraryJson); + + // actually create the LibraryPath directory + Directory.CreateDirectory(path); } /// diff --git a/StabilityMatrix/Helper/SnackbarService.cs b/StabilityMatrix/Helper/SnackbarService.cs index 766ea4f6..fc562812 100644 --- a/StabilityMatrix/Helper/SnackbarService.cs +++ b/StabilityMatrix/Helper/SnackbarService.cs @@ -1,7 +1,6 @@ using System.Threading.Tasks; using System; using AsyncAwaitBestPractices; -using Microsoft.Extensions.Logging; using StabilityMatrix.Models; using StabilityMatrix.ViewModels; using Wpf.Ui.Common; diff --git a/StabilityMatrix/LaunchPage.xaml.cs b/StabilityMatrix/LaunchPage.xaml.cs index b6451e9f..082c95a0 100644 --- a/StabilityMatrix/LaunchPage.xaml.cs +++ b/StabilityMatrix/LaunchPage.xaml.cs @@ -1,5 +1,4 @@ -using System; -using System.Windows; +using System.Windows; using System.Windows.Controls; using StabilityMatrix.ViewModels; diff --git a/StabilityMatrix/MainWindow.xaml.cs b/StabilityMatrix/MainWindow.xaml.cs index cf191bc7..5d9b37db 100644 --- a/StabilityMatrix/MainWindow.xaml.cs +++ b/StabilityMatrix/MainWindow.xaml.cs @@ -4,9 +4,7 @@ using System.Diagnostics; using System.Reactive.Linq; using System.Threading; using System.Windows; -using System.Windows.Forms; using System.Windows.Interop; -using CommunityToolkit.Mvvm.ComponentModel; using StabilityMatrix.Helper; using StabilityMatrix.Services; using StabilityMatrix.ViewModels; diff --git a/StabilityMatrix/Models/CheckpointFile.cs b/StabilityMatrix/Models/CheckpointFile.cs index d3b1683b..e99607cb 100644 --- a/StabilityMatrix/Models/CheckpointFile.cs +++ b/StabilityMatrix/Models/CheckpointFile.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; diff --git a/StabilityMatrix/Models/InstalledPackage.cs b/StabilityMatrix/Models/InstalledPackage.cs index 8a7691e7..38fcf920 100644 --- a/StabilityMatrix/Models/InstalledPackage.cs +++ b/StabilityMatrix/Models/InstalledPackage.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text.Json.Serialization; using System.Threading.Tasks; using StabilityMatrix.Helper; diff --git a/StabilityMatrix/Services/DownloadService.cs b/StabilityMatrix/Services/DownloadService.cs index 0e4cae23..d69ee498 100644 --- a/StabilityMatrix/Services/DownloadService.cs +++ b/StabilityMatrix/Services/DownloadService.cs @@ -5,7 +5,6 @@ using System.Net.Http.Headers; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Polly.Contrib.WaitAndRetry; -using StabilityMatrix.Models; using StabilityMatrix.Models.Progress; namespace StabilityMatrix.Services; diff --git a/StabilityMatrix/Services/IDownloadService.cs b/StabilityMatrix/Services/IDownloadService.cs index d8735d2e..03610107 100644 --- a/StabilityMatrix/Services/IDownloadService.cs +++ b/StabilityMatrix/Services/IDownloadService.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Tasks; -using StabilityMatrix.Models; using StabilityMatrix.Models.Progress; namespace StabilityMatrix.Services; diff --git a/StabilityMatrix/Updater/IUpdateHelper.cs b/StabilityMatrix/Updater/IUpdateHelper.cs index 0dbe9fc6..4987a2f0 100644 --- a/StabilityMatrix/Updater/IUpdateHelper.cs +++ b/StabilityMatrix/Updater/IUpdateHelper.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Tasks; -using StabilityMatrix.Models; using StabilityMatrix.Models.Progress; namespace StabilityMatrix.Updater; diff --git a/StabilityMatrix/Updater/UpdateHelper.cs b/StabilityMatrix/Updater/UpdateHelper.cs index a2fb3dfe..51c01c6a 100644 --- a/StabilityMatrix/Updater/UpdateHelper.cs +++ b/StabilityMatrix/Updater/UpdateHelper.cs @@ -9,7 +9,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using StabilityMatrix.Extensions; using StabilityMatrix.Helper; -using StabilityMatrix.Models; using StabilityMatrix.Models.Configs; using StabilityMatrix.Models.Progress; using StabilityMatrix.Services; diff --git a/StabilityMatrix/ViewModels/CheckpointBrowserViewModel.cs b/StabilityMatrix/ViewModels/CheckpointBrowserViewModel.cs index ae1d0ac2..9af2acf9 100644 --- a/StabilityMatrix/ViewModels/CheckpointBrowserViewModel.cs +++ b/StabilityMatrix/ViewModels/CheckpointBrowserViewModel.cs @@ -11,7 +11,6 @@ using NLog; using System.Diagnostics; using System.Net.Http; using System.Windows.Data; -using Octokit; using StabilityMatrix.Api; using StabilityMatrix.Database; using StabilityMatrix.Extensions; diff --git a/StabilityMatrix/ViewModels/CheckpointManagerViewModel.cs b/StabilityMatrix/ViewModels/CheckpointManagerViewModel.cs index 2be4dc9d..d28d8f99 100644 --- a/StabilityMatrix/ViewModels/CheckpointManagerViewModel.cs +++ b/StabilityMatrix/ViewModels/CheckpointManagerViewModel.cs @@ -1,6 +1,5 @@ using System.Collections.Concurrent; using System.Collections.ObjectModel; -using System.Diagnostics; using System.IO; using System.Linq; using System.Threading.Tasks; diff --git a/StabilityMatrix/ViewModels/LaunchViewModel.cs b/StabilityMatrix/ViewModels/LaunchViewModel.cs index 4135ca6f..a2848dd5 100644 --- a/StabilityMatrix/ViewModels/LaunchViewModel.cs +++ b/StabilityMatrix/ViewModels/LaunchViewModel.cs @@ -1,6 +1,5 @@ using System; using System.Collections.ObjectModel; -using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using System.Windows; diff --git a/StabilityMatrix/ViewModels/MainWindowViewModel.cs b/StabilityMatrix/ViewModels/MainWindowViewModel.cs index c0c04639..9857cf3e 100644 --- a/StabilityMatrix/ViewModels/MainWindowViewModel.cs +++ b/StabilityMatrix/ViewModels/MainWindowViewModel.cs @@ -1,5 +1,4 @@ using System; -using System.Dynamic; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -12,7 +11,6 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Microsoft.Extensions.Options; using StabilityMatrix.Helper; -using StabilityMatrix.Models; using StabilityMatrix.Models.Configs; using StabilityMatrix.Services; using StabilityMatrix.Updater; diff --git a/StabilityMatrix/ViewModels/RefreshBadgeViewModel.cs b/StabilityMatrix/ViewModels/RefreshBadgeViewModel.cs index 7a6b3a40..b282930a 100644 --- a/StabilityMatrix/ViewModels/RefreshBadgeViewModel.cs +++ b/StabilityMatrix/ViewModels/RefreshBadgeViewModel.cs @@ -5,7 +5,6 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using NLog; using StabilityMatrix.Controls; -using StabilityMatrix.Models; using StabilityMatrix.Models.Progress; using Wpf.Ui.Common; using Wpf.Ui.Controls; diff --git a/StabilityMatrix/ViewModels/SelectInstallLocationsViewModel.cs b/StabilityMatrix/ViewModels/SelectInstallLocationsViewModel.cs index d89c5813..d960a637 100644 --- a/StabilityMatrix/ViewModels/SelectInstallLocationsViewModel.cs +++ b/StabilityMatrix/ViewModels/SelectInstallLocationsViewModel.cs @@ -10,8 +10,6 @@ using CommunityToolkit.Mvvm.Input; using NLog; using Ookii.Dialogs.Wpf; using StabilityMatrix.Helper; -using StabilityMatrix.Models; -using StabilityMatrix.Models.FileInterfaces; using StabilityMatrix.Models.Progress; using StabilityMatrix.Models.Settings; diff --git a/StabilityMatrix/ViewModels/UpdateWindowViewModel.cs b/StabilityMatrix/ViewModels/UpdateWindowViewModel.cs index e2066c21..ab2b5cd2 100644 --- a/StabilityMatrix/ViewModels/UpdateWindowViewModel.cs +++ b/StabilityMatrix/ViewModels/UpdateWindowViewModel.cs @@ -6,7 +6,6 @@ using System.Windows; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using StabilityMatrix.Helper; -using StabilityMatrix.Models; using StabilityMatrix.Models.Progress; using StabilityMatrix.Updater; using Wpf.Ui.Controls.Window; diff --git a/StabilityMatrix/WebLoginDialog.xaml.cs b/StabilityMatrix/WebLoginDialog.xaml.cs index bbdc214b..714beafa 100644 --- a/StabilityMatrix/WebLoginDialog.xaml.cs +++ b/StabilityMatrix/WebLoginDialog.xaml.cs @@ -1,6 +1,5 @@ using System.Windows; using Microsoft.Web.WebView2.Core; -using NLog; using StabilityMatrix.ViewModels; using Wpf.Ui.Contracts; using Wpf.Ui.Controls.ContentDialogControl;