mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Blocks installations installed into non-empty folder w/o MO2 files
This commit is contained in:
parent
7c88b4ea12
commit
124f9e1d88
@ -323,6 +323,10 @@ namespace Wabbajack.Lib
|
||||
{
|
||||
var ret = Utils.IsDirectoryPathValid(path);
|
||||
if (!ret.Succeeded) return ret;
|
||||
|
||||
if (!Directory.Exists(path)) return ErrorResponse.Success;
|
||||
|
||||
// Check folder does not have a wabbajack modlist
|
||||
foreach (var file in Directory.EnumerateFiles(path, DirectoryEnumerationOptions.Recursive))
|
||||
{
|
||||
if (!File.Exists(file)) continue;
|
||||
@ -331,6 +335,23 @@ 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
|
||||
if (!Directory.IsEmpty(path))
|
||||
{
|
||||
// Some probably naive check, but should be a good starting point to improve later
|
||||
if (!Directory.EnumerateFiles(path).Any(file =>
|
||||
{
|
||||
var fileName = Path.GetFileName(file);
|
||||
if (fileName.Equals("ModOrganizer.exe", StringComparison.OrdinalIgnoreCase)) return true;
|
||||
if (fileName.Equals("ModOrganizer.ini", StringComparison.OrdinalIgnoreCase)) return true;
|
||||
return false;
|
||||
}))
|
||||
{
|
||||
return ErrorResponse.Fail($"Cannot install into a non-empty folder that does not look like a previous WJ installation.");
|
||||
}
|
||||
}
|
||||
|
||||
return ErrorResponse.Success;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user