Blocks installations into folders /w .wabbajack file

This commit is contained in:
Justin Swanson 2019-12-20 16:06:20 -06:00
parent caffb6e032
commit 7c88b4ea12
3 changed files with 17 additions and 2 deletions

View File

@ -144,7 +144,7 @@ namespace Wabbajack.CacheServer
{
foreach (var list in modlists)
{
var modlist_path = Path.Combine(Consts.ModListDownloadFolder, list.Links.MachineURL + ".wabbajack");
var modlist_path = Path.Combine(Consts.ModListDownloadFolder, list.Links.MachineURL + ExtensionManager.Extension);
if (list.NeedsDownload(modlist_path))
{

View File

@ -318,5 +318,20 @@ namespace Wabbajack.Lib
File.WriteAllText(Path.Combine(OutputFolder, directive.To), data);
}
public static IErrorResponse CheckValidInstallPath(string path)
{
var ret = Utils.IsDirectoryPathValid(path);
if (!ret.Succeeded) return ret;
foreach (var file in Directory.EnumerateFiles(path, DirectoryEnumerationOptions.Recursive))
{
if (!File.Exists(file)) continue;
if (System.IO.Path.GetExtension(file).Equals(ExtensionManager.Extension))
{
return ErrorResponse.Fail($"Cannot install into a folder with a wabbajack modlist inside of it.");
}
}
return ErrorResponse.Success;
}
}
}

View File

@ -48,7 +48,7 @@ namespace Wabbajack
PromptTitle = "Select Installation Directory",
};
Location.AdditionalError = this.WhenAny(x => x.Location.TargetPath)
.Select(x => Utils.IsDirectoryPathValid(x));
.Select(x => MO2Installer.CheckValidInstallPath(x));
DownloadLocation = new FilePickerVM()
{
ExistCheckOption = FilePickerVM.CheckOptions.Off,