mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fixed naming in Wabbajack.Lib
This commit is contained in:
parent
4eec277955
commit
b930724560
@ -10,7 +10,7 @@ namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
public class DeconstructBSAs : ACompilationStep
|
||||
{
|
||||
private readonly IEnumerable<string> _include_directly;
|
||||
private readonly IEnumerable<string> _includeDirectly;
|
||||
private readonly List<ICompilationStep> _microstack;
|
||||
private readonly List<ICompilationStep> _microstackWithInclude;
|
||||
private readonly MO2Compiler _mo2Compiler;
|
||||
@ -18,7 +18,7 @@ namespace Wabbajack.Lib.CompilationSteps
|
||||
public DeconstructBSAs(ACompiler compiler) : base(compiler)
|
||||
{
|
||||
_mo2Compiler = (MO2Compiler) compiler;
|
||||
_include_directly = _mo2Compiler.ModInis.Where(kv =>
|
||||
_includeDirectly = _mo2Compiler.ModInis.Where(kv =>
|
||||
{
|
||||
var general = kv.Value.General;
|
||||
if (general.notes != null && general.notes.Contains(Consts.WABBAJACK_INCLUDE)) return true;
|
||||
@ -54,16 +54,16 @@ namespace Wabbajack.Lib.CompilationSteps
|
||||
|
||||
var defaultInclude = false;
|
||||
if (source.Path.StartsWith("mods"))
|
||||
if (_include_directly.Any(path => source.Path.StartsWith(path)))
|
||||
if (_includeDirectly.Any(path => source.Path.StartsWith(path)))
|
||||
defaultInclude = true;
|
||||
|
||||
var source_files = source.File.Children;
|
||||
var sourceFiles = source.File.Children;
|
||||
|
||||
var stack = defaultInclude ? _microstackWithInclude : _microstack;
|
||||
|
||||
var id = Guid.NewGuid().ToString();
|
||||
|
||||
var matches = source_files.PMap(_mo2Compiler.Queue, e => _mo2Compiler.RunStack(stack, new RawSourceFile(e)
|
||||
var matches = sourceFiles.PMap(_mo2Compiler.Queue, e => _mo2Compiler.RunStack(stack, new RawSourceFile(e)
|
||||
{
|
||||
Path = Path.Combine(Consts.BSACreationDir, id, e.Name)
|
||||
}));
|
||||
|
@ -5,9 +5,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
public class DropboxDownloader : IDownloader, IUrlDownloader
|
||||
{
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archive_ini)
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archiveINI)
|
||||
{
|
||||
var urlstring = archive_ini?.General?.directURL;
|
||||
var urlstring = archiveINI?.General?.directURL;
|
||||
return GetDownloaderState(urlstring);
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
public class GoogleDriveDownloader : IDownloader, IUrlDownloader
|
||||
{
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archive_ini)
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archiveINI)
|
||||
{
|
||||
var url = archive_ini?.General?.directURL;
|
||||
var url = archiveINI?.General?.directURL;
|
||||
return GetDownloaderState(url);
|
||||
}
|
||||
|
||||
@ -47,14 +47,14 @@ namespace Wabbajack.Lib.Downloaders
|
||||
|
||||
private HTTPDownloader.State ToHttpState()
|
||||
{
|
||||
var initial_url = $"https://drive.google.com/uc?id={Id}&export=download";
|
||||
var initialURL = $"https://drive.google.com/uc?id={Id}&export=download";
|
||||
var client = new HttpClient();
|
||||
var result = client.GetStringSync(initial_url);
|
||||
var result = client.GetStringSync(initialURL);
|
||||
var regex = new Regex("(?<=/uc\\?export=download&confirm=).*(?=;id=)");
|
||||
var confirm = regex.Match(result);
|
||||
var url = $"https://drive.google.com/uc?export=download&confirm={confirm}&id={Id}";
|
||||
var http_state = new HTTPDownloader.State {Url = url, Client = client};
|
||||
return http_state;
|
||||
var httpState = new HTTPDownloader.State {Url = url, Client = client};
|
||||
return httpState;
|
||||
}
|
||||
|
||||
public override bool Verify()
|
||||
|
@ -13,10 +13,10 @@ namespace Wabbajack.Lib.Downloaders
|
||||
public class HTTPDownloader : IDownloader, IUrlDownloader
|
||||
{
|
||||
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archive_ini)
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archiveINI)
|
||||
{
|
||||
var url = archive_ini?.General?.directURL;
|
||||
return GetDownloaderState(url, archive_ini);
|
||||
var url = archiveINI?.General?.directURL;
|
||||
return GetDownloaderState(url, archiveINI);
|
||||
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
return GetDownloaderState(uri, null);
|
||||
}
|
||||
|
||||
public AbstractDownloadState GetDownloaderState(string url, dynamic archive_ini)
|
||||
public AbstractDownloadState GetDownloaderState(string url, dynamic archiveINI)
|
||||
{
|
||||
if (url != null)
|
||||
{
|
||||
@ -33,10 +33,10 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
Url = url
|
||||
};
|
||||
if (archive_ini?.General?.directURLHeaders != null)
|
||||
if (archiveINI?.General?.directURLHeaders != null)
|
||||
{
|
||||
tmp.Headers = new List<string>();
|
||||
tmp.Headers.AddRange(archive_ini?.General.directURLHeaders.Split('|'));
|
||||
tmp.Headers.AddRange(archiveINI?.General.directURLHeaders.Split('|'));
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
@ -82,8 +82,8 @@ namespace Wabbajack.Lib.Downloaders
|
||||
client.DefaultRequestHeaders.Add(k, v);
|
||||
}
|
||||
|
||||
long total_read = 0;
|
||||
var buffer_size = 1024 * 32;
|
||||
long totalRead = 0;
|
||||
var bufferSize = 1024 * 32;
|
||||
|
||||
var response = client.GetSync(Url);
|
||||
var stream = response.Content.ReadAsStreamAsync();
|
||||
@ -105,25 +105,25 @@ namespace Wabbajack.Lib.Downloaders
|
||||
if (!download)
|
||||
return true;
|
||||
|
||||
var header_var = a.Size == 0 ? "1" : a.Size.ToString();
|
||||
var headerVar = a.Size == 0 ? "1" : a.Size.ToString();
|
||||
if (response.Content.Headers.Contains("Content-Length"))
|
||||
header_var = response.Content.Headers.GetValues("Content-Length").FirstOrDefault();
|
||||
headerVar = response.Content.Headers.GetValues("Content-Length").FirstOrDefault();
|
||||
|
||||
var content_size = header_var != null ? long.Parse(header_var) : 1;
|
||||
var contentSize = headerVar != null ? long.Parse(headerVar) : 1;
|
||||
|
||||
|
||||
using (var webs = stream.Result)
|
||||
using (var fs = File.OpenWrite(destination))
|
||||
{
|
||||
var buffer = new byte[buffer_size];
|
||||
var buffer = new byte[bufferSize];
|
||||
while (true)
|
||||
{
|
||||
var read = webs.Read(buffer, 0, buffer_size);
|
||||
var read = webs.Read(buffer, 0, bufferSize);
|
||||
if (read == 0) break;
|
||||
Utils.Status($"Downloading {a.Name}", (int)(total_read * 100 / content_size));
|
||||
Utils.Status($"Downloading {a.Name}", (int)(totalRead * 100 / contentSize));
|
||||
|
||||
fs.Write(buffer, 0, read);
|
||||
total_read += read;
|
||||
totalRead += read;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
public interface IDownloader
|
||||
{
|
||||
AbstractDownloadState GetDownloaderState(dynamic archive_ini);
|
||||
AbstractDownloadState GetDownloaderState(dynamic archiveINI);
|
||||
|
||||
/// <summary>
|
||||
/// Called before any downloads are inacted by the installer;
|
||||
|
@ -7,9 +7,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
public class MegaDownloader : IDownloader, IUrlDownloader
|
||||
{
|
||||
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archive_ini)
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archiveINI)
|
||||
{
|
||||
var url = archive_ini?.General?.directURL;
|
||||
var url = archiveINI?.General?.directURL;
|
||||
return GetDownloaderState(url);
|
||||
}
|
||||
|
||||
@ -31,10 +31,10 @@ namespace Wabbajack.Lib.Downloaders
|
||||
var client = new MegaApiClient();
|
||||
Utils.Status("Logging into MEGA (as anonymous)");
|
||||
client.LoginAnonymous();
|
||||
var file_link = new Uri(Url);
|
||||
var node = client.GetNodeFromLink(file_link);
|
||||
var fileLink = new Uri(Url);
|
||||
var node = client.GetNodeFromLink(fileLink);
|
||||
Utils.Status($"Downloading MEGA file: {a.Name}");
|
||||
client.DownloadFile(file_link, destination);
|
||||
client.DownloadFile(fileLink, destination);
|
||||
}
|
||||
|
||||
public override bool Verify()
|
||||
@ -42,10 +42,10 @@ namespace Wabbajack.Lib.Downloaders
|
||||
var client = new MegaApiClient();
|
||||
Utils.Status("Logging into MEGA (as anonymous)");
|
||||
client.LoginAnonymous();
|
||||
var file_link = new Uri(Url);
|
||||
var fileLink = new Uri(Url);
|
||||
try
|
||||
{
|
||||
var node = client.GetNodeFromLink(file_link);
|
||||
var node = client.GetNodeFromLink(fileLink);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
|
@ -58,9 +58,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archive_ini)
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archiveINI)
|
||||
{
|
||||
var url = archive_ini?.General?.manualURL;
|
||||
var url = archiveINI?.General?.manualURL;
|
||||
return url != null ? new State { Url = url} : null;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
public override void Download(Archive a, string destination)
|
||||
{
|
||||
var downloader = (ManualDownloader)GetDownloader();
|
||||
var abs_path = Path.Combine(downloader._downloadfolder.Path, a.Name);
|
||||
var absPath = Path.Combine(downloader._downloadfolder.Path, a.Name);
|
||||
lock (downloader)
|
||||
{
|
||||
try
|
||||
@ -95,10 +95,10 @@ namespace Wabbajack.Lib.Downloaders
|
||||
.FirstOrDefaultAsync();
|
||||
Process.Start(Url);
|
||||
|
||||
abs_path = watcher.Wait()?.FullPath;
|
||||
if (!File.Exists(abs_path))
|
||||
absPath = watcher.Wait()?.FullPath;
|
||||
if (!File.Exists(absPath))
|
||||
throw new InvalidDataException($"File not found after manual download operation");
|
||||
File.Move(abs_path, destination);
|
||||
File.Move(absPath, destination);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -9,9 +9,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
public class MediaFireDownloader : IUrlDownloader
|
||||
{
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archive_ini)
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archiveINI)
|
||||
{
|
||||
Uri url = DownloaderUtils.GetDirectURL(archive_ini);
|
||||
Uri url = DownloaderUtils.GetDirectURL(archiveINI);
|
||||
if (url == null || url.Host != "www.mediafire.com") return null;
|
||||
|
||||
return new State
|
||||
@ -46,12 +46,12 @@ namespace Wabbajack.Lib.Downloaders
|
||||
await d.NavigateTo(new Uri("http://www.mediafire.com/file/agiqzm1xwebczpx/WABBAJACK_TEST_FILE.tx"));
|
||||
// MediaFire creates the link after all the JS loads
|
||||
await Task.Delay(1000);
|
||||
var new_url = await d.GetAttr("a.input", "href");
|
||||
if (new_url == null || !new_url.StartsWith("http")) return null;
|
||||
var newURL = await d.GetAttr("a.input", "href");
|
||||
if (newURL == null || !newURL.StartsWith("http")) return null;
|
||||
return new HTTPDownloader.State()
|
||||
{
|
||||
Client = new HttpClient(),
|
||||
Url = new_url
|
||||
Url = newURL
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
public class ModDBDownloader : IDownloader, IUrlDownloader
|
||||
{
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archive_ini)
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archiveINI)
|
||||
{
|
||||
var url = archive_ini?.General?.directURL;
|
||||
var url = archiveINI?.General?.directURL;
|
||||
return GetDownloaderState(url);
|
||||
}
|
||||
|
||||
@ -41,8 +41,8 @@ namespace Wabbajack.Lib.Downloaders
|
||||
|
||||
public override void Download(Archive a, string destination)
|
||||
{
|
||||
var new_url = GetDownloadUrl();
|
||||
new HTTPDownloader.State {Url = new_url}.Download(a, destination);
|
||||
var newURL = GetDownloadUrl();
|
||||
new HTTPDownloader.State {Url = newURL}.Download(a, destination);
|
||||
}
|
||||
|
||||
private string GetDownloadUrl()
|
||||
@ -51,14 +51,14 @@ namespace Wabbajack.Lib.Downloaders
|
||||
var result = client.GetStringSync(Url);
|
||||
var regex = new Regex("https:\\/\\/www\\.moddb\\.com\\/downloads\\/mirror\\/.*(?=\\\")");
|
||||
var match = regex.Match(result);
|
||||
var new_url = match.Value;
|
||||
return new_url;
|
||||
var newURL = match.Value;
|
||||
return newURL;
|
||||
}
|
||||
|
||||
public override bool Verify()
|
||||
{
|
||||
var new_url = GetDownloadUrl();
|
||||
return new HTTPDownloader.State { Url = new_url }.Verify();
|
||||
var newURL = GetDownloadUrl();
|
||||
return new HTTPDownloader.State { Url = newURL }.Verify();
|
||||
}
|
||||
|
||||
public override IDownloader GetDownloader()
|
||||
|
@ -8,9 +8,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
public class NexusDownloader : IDownloader
|
||||
{
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archive_ini)
|
||||
public AbstractDownloadState GetDownloaderState(dynamic archiveINI)
|
||||
{
|
||||
var general = archive_ini?.General;
|
||||
var general = archiveINI?.General;
|
||||
|
||||
if (general.modID != null && general.fileID != null && general.gameName != null)
|
||||
{
|
||||
|
@ -24,11 +24,11 @@ namespace Wabbajack.Lib
|
||||
|
||||
public string MO2Profile;
|
||||
|
||||
public MO2Compiler(string mo2_folder)
|
||||
public MO2Compiler(string mo2Folder)
|
||||
{
|
||||
ModManager = ModManager.MO2;
|
||||
|
||||
MO2Folder = mo2_folder;
|
||||
MO2Folder = mo2Folder;
|
||||
MO2Ini = Path.Combine(MO2Folder, "ModOrganizer.ini").LoadIniFile();
|
||||
GamePath = ((string)MO2Ini.General.gamePath).Replace("\\\\", "\\");
|
||||
|
||||
@ -68,9 +68,9 @@ namespace Wabbajack.Lib
|
||||
UpdateTracker.Reset();
|
||||
UpdateTracker.NextStep("Gathering information");
|
||||
Info("Looking for other profiles");
|
||||
var other_profiles_path = Path.Combine(MO2ProfileDir, "otherprofiles.txt");
|
||||
var otherProfilesPath = Path.Combine(MO2ProfileDir, "otherprofiles.txt");
|
||||
SelectedProfiles = new HashSet<string>();
|
||||
if (File.Exists(other_profiles_path)) SelectedProfiles = File.ReadAllLines(other_profiles_path).ToHashSet();
|
||||
if (File.Exists(otherProfilesPath)) SelectedProfiles = File.ReadAllLines(otherProfilesPath).ToHashSet();
|
||||
SelectedProfiles.Add(MO2Profile);
|
||||
|
||||
Info("Using Profiles: " + string.Join(", ", SelectedProfiles.OrderBy(p => p)));
|
||||
@ -104,31 +104,31 @@ namespace Wabbajack.Lib
|
||||
UpdateTracker.NextStep("Finding Install Files");
|
||||
Directory.CreateDirectory(ModListOutputFolder);
|
||||
|
||||
var mo2_files = Directory.EnumerateFiles(MO2Folder, "*", SearchOption.AllDirectories)
|
||||
var mo2Files = Directory.EnumerateFiles(MO2Folder, "*", SearchOption.AllDirectories)
|
||||
.Where(p => p.FileExists())
|
||||
.Select(p => new RawSourceFile(VFS.Index.ByRootPath[p]) { Path = p.RelativeTo(MO2Folder) });
|
||||
|
||||
var game_files = Directory.EnumerateFiles(GamePath, "*", SearchOption.AllDirectories)
|
||||
var gameFiles = Directory.EnumerateFiles(GamePath, "*", SearchOption.AllDirectories)
|
||||
.Where(p => p.FileExists())
|
||||
.Select(p => new RawSourceFile(VFS.Index.ByRootPath[p])
|
||||
{ Path = Path.Combine(Consts.GameFolderFilesDir, p.RelativeTo(GamePath)) });
|
||||
|
||||
var loot_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
var lootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
"LOOT");
|
||||
|
||||
// TODO: make this generic so we can add more paths
|
||||
IEnumerable<RawSourceFile> loot_files = new List<RawSourceFile>();
|
||||
if (Directory.Exists(loot_path))
|
||||
IEnumerable<RawSourceFile> lootFiles = new List<RawSourceFile>();
|
||||
if (Directory.Exists(lootPath))
|
||||
{
|
||||
Info($"Indexing {loot_path}");
|
||||
VFS.AddRoot(loot_path);
|
||||
Info($"Indexing {lootPath}");
|
||||
VFS.AddRoot(lootPath);
|
||||
VFS.WriteToFile(_vfsCacheName);
|
||||
|
||||
|
||||
loot_files = Directory.EnumerateFiles(loot_path, "userlist.yaml", SearchOption.AllDirectories)
|
||||
lootFiles = Directory.EnumerateFiles(lootPath, "userlist.yaml", SearchOption.AllDirectories)
|
||||
.Where(p => p.FileExists())
|
||||
.Select(p => new RawSourceFile(VFS.Index.ByRootPath[p])
|
||||
{ Path = Path.Combine(Consts.LOOTFolderFilesDir, p.RelativeTo(loot_path)) });
|
||||
{ Path = Path.Combine(Consts.LOOTFolderFilesDir, p.RelativeTo(lootPath)) });
|
||||
}
|
||||
|
||||
IndexedArchives = Directory.EnumerateFiles(MO2DownloadsFolder)
|
||||
@ -147,8 +147,8 @@ namespace Wabbajack.Lib
|
||||
.GroupBy(f => f.Hash)
|
||||
.ToDictionary(f => f.Key, f => f.AsEnumerable());
|
||||
|
||||
AllFiles = mo2_files.Concat(game_files)
|
||||
.Concat(loot_files)
|
||||
AllFiles = mo2Files.Concat(gameFiles)
|
||||
.Concat(lootFiles)
|
||||
.DistinctBy(f => f.Path)
|
||||
.ToList();
|
||||
|
||||
@ -173,10 +173,10 @@ namespace Wabbajack.Lib
|
||||
ModInis = Directory.EnumerateDirectories(Path.Combine(MO2Folder, "mods"))
|
||||
.Select(f =>
|
||||
{
|
||||
var mod_name = Path.GetFileName(f);
|
||||
var meta_path = Path.Combine(f, "meta.ini");
|
||||
if (File.Exists(meta_path))
|
||||
return (mod_name, meta_path.LoadIniFile());
|
||||
var modName = Path.GetFileName(f);
|
||||
var metaPath = Path.Combine(f, "meta.ini");
|
||||
if (File.Exists(metaPath))
|
||||
return (mod_name: modName, metaPath.LoadIniFile());
|
||||
return (null, null);
|
||||
})
|
||||
.Where(f => f.Item2 != null)
|
||||
@ -294,48 +294,48 @@ namespace Wabbajack.Lib
|
||||
.ToList();
|
||||
|
||||
Info($"Patching building patches from {groups.Count} archives");
|
||||
var absolute_paths = AllFiles.ToDictionary(e => e.Path, e => e.AbsolutePath);
|
||||
groups.PMap(Queue, group => BuildArchivePatches(group.Key, group, absolute_paths));
|
||||
var absolutePaths = AllFiles.ToDictionary(e => e.Path, e => e.AbsolutePath);
|
||||
groups.PMap(Queue, group => BuildArchivePatches(group.Key, group, absolutePaths));
|
||||
|
||||
if (InstallDirectives.OfType<PatchedFromArchive>().FirstOrDefault(f => f.PatchID == null) != null)
|
||||
Error("Missing patches after generation, this should not happen");
|
||||
}
|
||||
|
||||
private void BuildArchivePatches(string archive_sha, IEnumerable<PatchedFromArchive> group,
|
||||
Dictionary<string, string> absolute_paths)
|
||||
private void BuildArchivePatches(string archiveSha, IEnumerable<PatchedFromArchive> group,
|
||||
Dictionary<string, string> absolutePaths)
|
||||
{
|
||||
using (var files = VFS.StageWith(group.Select(g => VFS.Index.FileForArchiveHashPath(g.ArchiveHashPath))))
|
||||
{
|
||||
var by_path = files.GroupBy(f => string.Join("|", f.FilesInFullPath.Skip(1).Select(i => i.Name)))
|
||||
var byPath = files.GroupBy(f => string.Join("|", f.FilesInFullPath.Skip(1).Select(i => i.Name)))
|
||||
.ToDictionary(f => f.Key, f => f.First());
|
||||
// Now Create the patches
|
||||
group.PMap(Queue, entry =>
|
||||
{
|
||||
Info($"Patching {entry.To}");
|
||||
Status($"Patching {entry.To}");
|
||||
using (var origin = by_path[string.Join("|", entry.ArchiveHashPath.Skip(1))].OpenRead())
|
||||
using (var origin = byPath[string.Join("|", entry.ArchiveHashPath.Skip(1))].OpenRead())
|
||||
using (var output = new MemoryStream())
|
||||
{
|
||||
var a = origin.ReadAll();
|
||||
var b = LoadDataForTo(entry.To, absolute_paths).Result;
|
||||
var b = LoadDataForTo(entry.To, absolutePaths).Result;
|
||||
Utils.CreatePatch(a, b, output);
|
||||
entry.PatchID = IncludeFile(output.ToArray());
|
||||
var file_size = File.GetSize(Path.Combine(ModListOutputFolder, entry.PatchID));
|
||||
Info($"Patch size {file_size} for {entry.To}");
|
||||
var fileSize = File.GetSize(Path.Combine(ModListOutputFolder, entry.PatchID));
|
||||
Info($"Patch size {fileSize} for {entry.To}");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<byte[]> LoadDataForTo(string to, Dictionary<string, string> absolute_paths)
|
||||
private async Task<byte[]> LoadDataForTo(string to, Dictionary<string, string> absolutePaths)
|
||||
{
|
||||
if (absolute_paths.TryGetValue(to, out var absolute))
|
||||
if (absolutePaths.TryGetValue(to, out var absolute))
|
||||
return File.ReadAllBytes(absolute);
|
||||
|
||||
if (to.StartsWith(Consts.BSACreationDir))
|
||||
{
|
||||
var bsa_id = to.Split('\\')[1];
|
||||
var bsa = InstallDirectives.OfType<CreateBSA>().First(b => b.TempID == bsa_id);
|
||||
var bsaID = to.Split('\\')[1];
|
||||
var bsa = InstallDirectives.OfType<CreateBSA>().First(b => b.TempID == bsaID);
|
||||
|
||||
using (var a = BSADispatch.OpenRead(Path.Combine(MO2Folder, bsa.To)))
|
||||
{
|
||||
@ -355,9 +355,9 @@ namespace Wabbajack.Lib
|
||||
|
||||
public override IEnumerable<ICompilationStep> GetStack()
|
||||
{
|
||||
var user_config = Path.Combine(MO2ProfileDir, "compilation_stack.yml");
|
||||
if (File.Exists(user_config))
|
||||
return Serialization.Deserialize(File.ReadAllText(user_config), this);
|
||||
var userConfig = Path.Combine(MO2ProfileDir, "compilation_stack.yml");
|
||||
if (File.Exists(userConfig))
|
||||
return Serialization.Deserialize(File.ReadAllText(userConfig), this);
|
||||
|
||||
var stack = MakeStack();
|
||||
|
||||
|
@ -17,13 +17,13 @@ namespace Wabbajack.Lib
|
||||
{
|
||||
public bool WarnOnOverwrite { get; set; } = true;
|
||||
|
||||
public MO2Installer(string archive, ModList mod_list, string output_folder)
|
||||
public MO2Installer(string archive, ModList modList, string outputFolder)
|
||||
{
|
||||
ModManager = ModManager.MO2;
|
||||
ModListArchive = archive;
|
||||
OutputFolder = output_folder;
|
||||
OutputFolder = outputFolder;
|
||||
DownloadFolder = Path.Combine(OutputFolder, "downloads");
|
||||
ModList = mod_list;
|
||||
ModList = modList;
|
||||
}
|
||||
|
||||
public string GameFolder { get; set; }
|
||||
@ -109,9 +109,9 @@ namespace Wabbajack.Lib
|
||||
.PMap(Queue, directive =>
|
||||
{
|
||||
Status($"Writing included .meta file {directive.To}");
|
||||
var out_path = Path.Combine(DownloadFolder, directive.To);
|
||||
if (File.Exists(out_path)) File.Delete(out_path);
|
||||
File.WriteAllBytes(out_path, LoadBytesFromPath(directive.SourceDataID));
|
||||
var outPath = Path.Combine(DownloadFolder, directive.To);
|
||||
if (File.Exists(outPath)) File.Delete(outPath);
|
||||
File.WriteAllBytes(outPath, LoadBytesFromPath(directive.SourceDataID));
|
||||
});
|
||||
}
|
||||
|
||||
@ -120,9 +120,9 @@ namespace Wabbajack.Lib
|
||||
foreach (var esm in ModList.Directives.OfType<CleanedESM>().ToList())
|
||||
{
|
||||
var filename = Path.GetFileName(esm.To);
|
||||
var game_file = Path.Combine(GameFolder, "Data", filename);
|
||||
var gameFile = Path.Combine(GameFolder, "Data", filename);
|
||||
Utils.Log($"Validating {filename}");
|
||||
var hash = game_file.FileHash();
|
||||
var hash = gameFile.FileHash();
|
||||
if (hash != esm.SourceESMHash)
|
||||
{
|
||||
Utils.Error("Game ESM hash doesn't match, is the ESM already cleaned? Please verify your local game files.");
|
||||
@ -173,14 +173,14 @@ namespace Wabbajack.Lib
|
||||
bsas.Do(bsa =>
|
||||
{
|
||||
Status($"Building {bsa.To}");
|
||||
var source_dir = Path.Combine(OutputFolder, Consts.BSACreationDir, bsa.TempID);
|
||||
var sourceDir = Path.Combine(OutputFolder, Consts.BSACreationDir, bsa.TempID);
|
||||
|
||||
using (var a = bsa.State.MakeBuilder())
|
||||
{
|
||||
bsa.FileStates.PMap(Queue, state =>
|
||||
{
|
||||
Status($"Adding {state.Path} to BSA");
|
||||
using (var fs = File.OpenRead(Path.Combine(source_dir, state.Path)))
|
||||
using (var fs = File.OpenRead(Path.Combine(sourceDir, state.Path)))
|
||||
{
|
||||
a.AddFile(state, fs);
|
||||
}
|
||||
@ -192,11 +192,11 @@ namespace Wabbajack.Lib
|
||||
});
|
||||
|
||||
|
||||
var bsa_dir = Path.Combine(OutputFolder, Consts.BSACreationDir);
|
||||
if (Directory.Exists(bsa_dir))
|
||||
var bsaDir = Path.Combine(OutputFolder, Consts.BSACreationDir);
|
||||
if (Directory.Exists(bsaDir))
|
||||
{
|
||||
Info($"Removing temp folder {Consts.BSACreationDir}");
|
||||
Directory.Delete(bsa_dir, true, true);
|
||||
Directory.Delete(bsaDir, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,36 +208,36 @@ namespace Wabbajack.Lib
|
||||
.PMap(Queue, directive =>
|
||||
{
|
||||
Status($"Writing included file {directive.To}");
|
||||
var out_path = Path.Combine(OutputFolder, directive.To);
|
||||
if (File.Exists(out_path)) File.Delete(out_path);
|
||||
var outPath = Path.Combine(OutputFolder, directive.To);
|
||||
if (File.Exists(outPath)) File.Delete(outPath);
|
||||
if (directive is RemappedInlineFile)
|
||||
WriteRemappedFile((RemappedInlineFile)directive);
|
||||
else if (directive is CleanedESM)
|
||||
GenerateCleanedESM((CleanedESM)directive);
|
||||
else
|
||||
File.WriteAllBytes(out_path, LoadBytesFromPath(directive.SourceDataID));
|
||||
File.WriteAllBytes(outPath, LoadBytesFromPath(directive.SourceDataID));
|
||||
});
|
||||
}
|
||||
|
||||
private void GenerateCleanedESM(CleanedESM directive)
|
||||
{
|
||||
var filename = Path.GetFileName(directive.To);
|
||||
var game_file = Path.Combine(GameFolder, "Data", filename);
|
||||
var gameFile = Path.Combine(GameFolder, "Data", filename);
|
||||
Info($"Generating cleaned ESM for {filename}");
|
||||
if (!File.Exists(game_file)) throw new InvalidDataException($"Missing {filename} at {game_file}");
|
||||
if (!File.Exists(gameFile)) throw new InvalidDataException($"Missing {filename} at {gameFile}");
|
||||
Status($"Hashing game version of {filename}");
|
||||
var sha = game_file.FileHash();
|
||||
var sha = gameFile.FileHash();
|
||||
if (sha != directive.SourceESMHash)
|
||||
throw new InvalidDataException(
|
||||
$"Cannot patch {filename} from the game folder hashes don't match have you already cleaned the file?");
|
||||
|
||||
var patch_data = LoadBytesFromPath(directive.SourceDataID);
|
||||
var to_file = Path.Combine(OutputFolder, directive.To);
|
||||
var patchData = LoadBytesFromPath(directive.SourceDataID);
|
||||
var toFile = Path.Combine(OutputFolder, directive.To);
|
||||
Status($"Patching {filename}");
|
||||
using (var output = File.OpenWrite(to_file))
|
||||
using (var input = File.OpenRead(game_file))
|
||||
using (var output = File.OpenWrite(toFile))
|
||||
using (var input = File.OpenRead(gameFile))
|
||||
{
|
||||
BSDiff.Apply(input, () => new MemoryStream(patch_data), output);
|
||||
BSDiff.Apply(input, () => new MemoryStream(patchData), output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,19 +11,19 @@ namespace Wabbajack.Lib
|
||||
public class ReportBuilder : IDisposable
|
||||
{
|
||||
private const int WRAP_SIZE = 80;
|
||||
private readonly StreamWriter wtr;
|
||||
private string _output_folder;
|
||||
private readonly StreamWriter _wtr;
|
||||
private string _outputFolder;
|
||||
|
||||
public ReportBuilder(Stream str, string output_folder)
|
||||
public ReportBuilder(Stream str, string outputFolder)
|
||||
{
|
||||
_output_folder = output_folder;
|
||||
wtr = new StreamWriter(str);
|
||||
_outputFolder = outputFolder;
|
||||
_wtr = new StreamWriter(str);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
wtr.Flush();
|
||||
wtr?.Dispose();
|
||||
_wtr.Flush();
|
||||
_wtr?.Dispose();
|
||||
}
|
||||
|
||||
public void Text(string txt)
|
||||
@ -31,16 +31,16 @@ namespace Wabbajack.Lib
|
||||
var offset = 0;
|
||||
while (offset + WRAP_SIZE < txt.Length)
|
||||
{
|
||||
wtr.WriteLine(txt.Substring(offset, WRAP_SIZE));
|
||||
_wtr.WriteLine(txt.Substring(offset, WRAP_SIZE));
|
||||
offset += WRAP_SIZE;
|
||||
}
|
||||
|
||||
if (offset < txt.Length) wtr.WriteLine(txt.Substring(offset, txt.Length - offset));
|
||||
if (offset < txt.Length) _wtr.WriteLine(txt.Substring(offset, txt.Length - offset));
|
||||
}
|
||||
|
||||
public void NoWrapText(string txt)
|
||||
{
|
||||
wtr.WriteLine(txt);
|
||||
_wtr.WriteLine(txt);
|
||||
}
|
||||
|
||||
public void Build(ACompiler c, ModList lst)
|
||||
@ -58,9 +58,9 @@ namespace Wabbajack.Lib
|
||||
|
||||
if (lst.ModManager == ModManager.MO2)
|
||||
{
|
||||
var readme_file = Path.Combine(compiler?.MO2ProfileDir, "readme.md");
|
||||
if (File.Exists(readme_file))
|
||||
File.ReadAllLines(readme_file)
|
||||
var readmeFile = Path.Combine(compiler?.MO2ProfileDir, "readme.md");
|
||||
if (File.Exists(readmeFile))
|
||||
File.ReadAllLines(readmeFile)
|
||||
.Do(NoWrapText);
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
private long SizeForID(string id)
|
||||
{
|
||||
return File.GetSize(Path.Combine(_output_folder, id));
|
||||
return File.GetSize(Path.Combine(_outputFolder, id));
|
||||
}
|
||||
|
||||
private IEnumerable<Archive> SortArchives(List<Archive> lstArchives)
|
||||
|
@ -8,14 +8,14 @@ namespace Wabbajack.Lib
|
||||
{
|
||||
public class ViewModel : ReactiveObject, IDisposable
|
||||
{
|
||||
private readonly Lazy<CompositeDisposable> _CompositeDisposable = new Lazy<CompositeDisposable>();
|
||||
public CompositeDisposable CompositeDisposable => _CompositeDisposable.Value;
|
||||
private readonly Lazy<CompositeDisposable> _compositeDisposable = new Lazy<CompositeDisposable>();
|
||||
public CompositeDisposable CompositeDisposable => _compositeDisposable.Value;
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (_CompositeDisposable.IsValueCreated)
|
||||
if (_compositeDisposable.IsValueCreated)
|
||||
{
|
||||
_CompositeDisposable.Value.Dispose();
|
||||
_compositeDisposable.Value.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user