Merge pull request 'detect downloads folder' (#35) from waffle.lord/SPT-AKI-Installer:master into master
Reviewed-on: CWX/SPT-AKI-Installer#35
This commit is contained in:
commit
47357ff056
@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
@ -143,13 +144,50 @@ public static class FileHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CheckPathForProblemLocations(string path)
|
private enum PathCheckType
|
||||||
{
|
{
|
||||||
if (path.ToLower().EndsWith("desktop")) return true;
|
EndsWith = 0,
|
||||||
|
Contains = 1,
|
||||||
|
}
|
||||||
|
|
||||||
var problemNames = new string[] {"onedrive", "nextcloud", "dropbox", "google" };
|
public static bool CheckPathForProblemLocations(string path, out string detectedName)
|
||||||
|
{
|
||||||
|
detectedName = "";
|
||||||
|
|
||||||
return problemNames.Where(x => path.ToLower().Contains(x)).Count() > 0;
|
var problemNames = new Dictionary<string, PathCheckType>()
|
||||||
|
{
|
||||||
|
{ "Desktop", PathCheckType.EndsWith },
|
||||||
|
{ "Downloads", PathCheckType.EndsWith },
|
||||||
|
{ "OneDrive", PathCheckType.Contains },
|
||||||
|
{ "NextCloud", PathCheckType.Contains },
|
||||||
|
{ "DropBox", PathCheckType.Contains },
|
||||||
|
{ "Google", PathCheckType.Contains },
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var name in problemNames)
|
||||||
|
{
|
||||||
|
switch (name.Value)
|
||||||
|
{
|
||||||
|
case PathCheckType.EndsWith:
|
||||||
|
if (path.ToLower().EndsWith(name.Key.ToLower()))
|
||||||
|
{
|
||||||
|
detectedName = name.Key;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PathCheckType.Contains:
|
||||||
|
if (path.ToLower().Contains(name.Key.ToLower()))
|
||||||
|
{
|
||||||
|
detectedName = name.Key;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -9,8 +9,8 @@
|
|||||||
<PackageIcon>icon.ico</PackageIcon>
|
<PackageIcon>icon.ico</PackageIcon>
|
||||||
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
||||||
<Configurations>Debug;Release;TEST</Configurations>
|
<Configurations>Debug;Release;TEST</Configurations>
|
||||||
<AssemblyVersion>2.15</AssemblyVersion>
|
<AssemblyVersion>2.16</AssemblyVersion>
|
||||||
<FileVersion>2.15</FileVersion>
|
<FileVersion>2.16</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -110,12 +110,12 @@ public class PreChecksViewModel : ViewModelBase
|
|||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
if (FileHelper.CheckPathForProblemLocations(InstallPath))
|
if (FileHelper.CheckPathForProblemLocations(InstallPath, out var detectedName))
|
||||||
{
|
{
|
||||||
await Dispatcher.UIThread.InvokeAsync(async () =>
|
await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||||
{
|
{
|
||||||
Log.Warning("Problem folder detected, confirming install path ...");
|
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}"));
|
var confirmation = await DialogHost.Show(new ConfirmationDialog($"We suspect you may be installing into a problematic folder: {detectedName}.\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)
|
if (confirmation == null || !bool.TryParse(confirmation.ToString(), out var confirm) || !confirm)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user