diff --git a/SPTInstaller/Helpers/FileHelper.cs b/SPTInstaller/Helpers/FileHelper.cs index 27319b7..f3513b6 100644 --- a/SPTInstaller/Helpers/FileHelper.cs +++ b/SPTInstaller/Helpers/FileHelper.cs @@ -113,11 +113,11 @@ public static class FileHelper public static bool CheckPathForProblemLocations(string path) { - if (path.EndsWith("Desktop")) return false; + if (path.ToLower().EndsWith("desktop")) return true; - var problemNames = new string[] {"OneDrive", "NextCloud", "DropBox", "Google" }; + var problemNames = new string[] {"onedrive", "nextcloud", "dropbox", "google" }; - return problemNames.Where(x => path.Contains(x)).Count() > 0; + return problemNames.Where(x => path.ToLower().Contains(x)).Count() > 0; } } \ No newline at end of file diff --git a/SPTInstaller/ViewModels/PreChecksViewModel.cs b/SPTInstaller/ViewModels/PreChecksViewModel.cs index 93eea80..d03365d 100644 --- a/SPTInstaller/ViewModels/PreChecksViewModel.cs +++ b/SPTInstaller/ViewModels/PreChecksViewModel.cs @@ -2,6 +2,7 @@ using System.Reflection; using System.Threading.Tasks; using System.Windows.Input; +using Avalonia.Threading; using DialogHostAvalonia; using ReactiveUI; using Serilog; @@ -71,18 +72,28 @@ public class PreChecksViewModel : ViewModelBase Log.Information($"Install Path: {FileHelper.GetRedactedPath(InstallPath)}"); + Task.Run(async () => + { + if (FileHelper.CheckPathForProblemLocations(InstallPath)) + { + await Dispatcher.UIThread.InvokeAsync(async () => + { + Log.Warning("Problem folder detected, confirming install path ..."); + var confirmation = await DialogHost.Show(new ConfirmationDialog($"We suspect you may be installing to your desktop or a cloud synced folder.\nYou might want to consider installing somewhere else to avoid issues.\n\nAre you sure you want to install to this path?\n{InstallPath}")); + + if (confirmation == null || !bool.TryParse(confirmation.ToString(), out var confirm) || !confirm) + { + Log.Information("User declined install path, exiting"); + Environment.Exit(0); + } + }); + + Log.Information("User accepted install path"); + } + }); + StartInstallCommand = ReactiveCommand.Create(async () => { - if(FileHelper.CheckPathForProblemLocations(InstallPath)) - { - var confirmation = await DialogHost.Show(new ConfirmationDialog($"We suspect you may be installing to your desktop or a cloud synced folder.\nYou might want to considering installing somewhere else to avoid issues.\n\nAre you sure you want to install to this path?\n{InstallPath}")); - - if (confirmation == null || !bool.TryParse(confirmation.ToString(), out var confirm) || !confirm) - { - return; - } - } - UpdateInfo.ShowCard = false; NavigateTo(new InstallViewModel(HostScreen)); });