Add a folder checker to CheckValidInstallPath.

This commit is contained in:
Unnoen 2020-08-07 23:22:48 +10:00
parent 8fed7ec25f
commit c3f34fedde
No known key found for this signature in database
GPG Key ID: F370906A9D954C50
2 changed files with 13 additions and 1 deletions

View File

@ -113,6 +113,7 @@ namespace Wabbajack.Common
public static int WabbajackCachePort = 80;
public static int MaxHTTPRetries = 4;
public static RelativePath MO2ModFolderName = (RelativePath)"mods";
public static RelativePath MO2ProfilesFolderName = (RelativePath)"profiles";
public static AbsolutePath PatchCacheFolder => LocalAppDataPath.Combine("patch_cache");
public static int MaxConnectionsPerServer = 4;

View File

@ -21,6 +21,7 @@ using Directory = Alphaleonis.Win32.Filesystem.Directory;
using File = Alphaleonis.Win32.Filesystem.File;
using Path = Alphaleonis.Win32.Filesystem.Path;
using SectionData = Wabbajack.Common.SectionData;
using System.Collections.Generic;
namespace Wabbajack.Lib
{
@ -428,12 +429,22 @@ namespace Wabbajack.Lib
return ErrorResponse.Fail($"Cannot install into a folder with a Wabbajack ModList inside of it");
}
// Check folder is either empty, or a likely valid previous install
// Check if folder is empty
if (path.IsEmptyDirectory)
{
return ErrorResponse.Success;
}
// Check if folders indicative of a previous install exist
var checks = new List<RelativePath>() {
Consts.MO2ModFolderName,
Consts.MO2ProfilesFolderName
};
if (checks.All(c => path.Combine(c).Exists))
{
return ErrorResponse.Success;
}
// If we have a MO2 install, assume good to go
if (path.EnumerateFiles(false).Any(file =>
{