From c3f34feddec266f34f63775bf5139d60dd82a8c2 Mon Sep 17 00:00:00 2001 From: Unnoen Date: Fri, 7 Aug 2020 23:22:48 +1000 Subject: [PATCH] Add a folder checker to CheckValidInstallPath. --- Wabbajack.Common/Consts.cs | 1 + Wabbajack.Lib/MO2Installer.cs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Wabbajack.Common/Consts.cs b/Wabbajack.Common/Consts.cs index 3150c51b..2e8b593c 100644 --- a/Wabbajack.Common/Consts.cs +++ b/Wabbajack.Common/Consts.cs @@ -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; diff --git a/Wabbajack.Lib/MO2Installer.cs b/Wabbajack.Lib/MO2Installer.cs index 652305c7..92877a92 100644 --- a/Wabbajack.Lib/MO2Installer.cs +++ b/Wabbajack.Lib/MO2Installer.cs @@ -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() { + 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 => {