From 550d744b076caef49dad27b9455beced334c4f30 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Sat, 28 May 2022 16:53:52 -0600 Subject: [PATCH] Compiler fixes --- Wabbajack.CLI/Verbs/InstallCompileInstallVerify.cs | 4 +++- Wabbajack.Compiler/ACompiler.cs | 2 +- Wabbajack.Downloaders.Http/HttpDownloader.cs | 2 +- Wabbajack.Installer/StandardInstaller.cs | 7 +++++-- Wabbajack.Paths/AbsolutePath.cs | 9 ++++++--- Wabbajack.Paths/RelativePath.cs | 9 +++++++-- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Wabbajack.CLI/Verbs/InstallCompileInstallVerify.cs b/Wabbajack.CLI/Verbs/InstallCompileInstallVerify.cs index 96b2b9f6..3a13ad5d 100644 --- a/Wabbajack.CLI/Verbs/InstallCompileInstallVerify.cs +++ b/Wabbajack.CLI/Verbs/InstallCompileInstallVerify.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.Common; using Wabbajack.Compiler; using Wabbajack.Downloaders; using Wabbajack.Downloaders.GameFile; @@ -61,7 +62,7 @@ public class InstallCompileInstallVerify : IVerb foreach (var machineUrl in machineUrls) { _logger.LogInformation("Installing {MachineUrl}", machineUrl); - var wabbajackPath = downloads.Combine(machineUrl.Replace("/", "_@@_")); + var wabbajackPath = downloads.Combine(machineUrl.Replace("/", "_@@_")).WithExtension(Ext.Wabbajack); if (!await DownloadMachineUrl(machineUrl, wabbajackPath, token)) throw new Exception("Can't download modlist"); @@ -86,6 +87,7 @@ public class InstallCompileInstallVerify : IVerb return 1; } + _logger.LogInformation("Inferring settings"); var inferedSettings = await _inferencer.InferFromRootPath(installPath); if (inferedSettings == null) diff --git a/Wabbajack.Compiler/ACompiler.cs b/Wabbajack.Compiler/ACompiler.cs index 05dcf274..1865fff4 100644 --- a/Wabbajack.Compiler/ACompiler.cs +++ b/Wabbajack.Compiler/ACompiler.cs @@ -310,7 +310,7 @@ public abstract class ACompiler catch (Exception e) { _logger.LogCritical(e, $"Exception while checking meta {filename}"); - return false; + return true; } } diff --git a/Wabbajack.Downloaders.Http/HttpDownloader.cs b/Wabbajack.Downloaders.Http/HttpDownloader.cs index 7133dbdd..ecda4368 100644 --- a/Wabbajack.Downloaders.Http/HttpDownloader.cs +++ b/Wabbajack.Downloaders.Http/HttpDownloader.cs @@ -100,7 +100,7 @@ public class HttpDownloader : ADownloader, IUrlDownloa { var msg = MakeMessage(state); - return await _client.SendAsync(msg, token); + return await _client.SendAsync(msg, HttpCompletionOption.ResponseHeadersRead, token); } internal static HttpRequestMessage MakeMessage(DTOs.DownloadStates.Http state) diff --git a/Wabbajack.Installer/StandardInstaller.cs b/Wabbajack.Installer/StandardInstaller.cs index 723ad9cf..2bfd50e2 100644 --- a/Wabbajack.Installer/StandardInstaller.cs +++ b/Wabbajack.Installer/StandardInstaller.cs @@ -222,7 +222,8 @@ public class StandardInstaller : AInstaller if (HashedArchives.TryGetValue(archive.Hash, out var paths)) { var metaPath = paths.WithExtension(Ext.Meta); - if (!metaPath.FileExists() && archive.State is not GameFileSource) + if (archive.State is GameFileSource) return; + if (!metaPath.FileExists()) { var meta = AddInstalled(_downloadDispatcher.MetaIni(archive)); await metaPath.WriteAllLinesAsync(meta, token); @@ -233,10 +234,12 @@ public class StandardInstaller : AInstaller private IEnumerable AddInstalled(IEnumerable getMetaIni) { + yield return "[General]"; + yield return "installed=true"; + foreach (var f in getMetaIni) { yield return f; - if (f == "[General]") yield return "installed=true"; } } diff --git a/Wabbajack.Paths/AbsolutePath.cs b/Wabbajack.Paths/AbsolutePath.cs index 4daa451e..959c9f13 100644 --- a/Wabbajack.Paths/AbsolutePath.cs +++ b/Wabbajack.Paths/AbsolutePath.cs @@ -10,12 +10,13 @@ public enum PathFormat : byte Unix } -public readonly struct AbsolutePath : IPath, IComparable, IEquatable +public struct AbsolutePath : IPath, IComparable, IEquatable { public static readonly AbsolutePath Empty = "".ToAbsolutePath(); public PathFormat PathFormat { get; } - + private int _hashCode = 0; + internal readonly string[] Parts; public Extension Extension => Extension.FromPath(Parts[^1]); @@ -93,8 +94,10 @@ public readonly struct AbsolutePath : IPath, IComparable, IEquatab public override int GetHashCode() { - return Parts.Aggregate(0, + if (_hashCode != 0) return _hashCode; + _hashCode = Parts.Aggregate(0, (current, part) => current ^ part.GetHashCode(StringComparison.CurrentCultureIgnoreCase)); + return _hashCode; } public override bool Equals(object? obj) diff --git a/Wabbajack.Paths/RelativePath.cs b/Wabbajack.Paths/RelativePath.cs index 49d38a84..16984cf0 100644 --- a/Wabbajack.Paths/RelativePath.cs +++ b/Wabbajack.Paths/RelativePath.cs @@ -3,10 +3,12 @@ using System.Linq; namespace Wabbajack.Paths; -public readonly struct RelativePath : IPath, IEquatable, IComparable +public struct RelativePath : IPath, IEquatable, IComparable { internal readonly string[] Parts; + private int _hashCode = 0; + internal RelativePath(string[] parts) { Parts = parts; @@ -79,8 +81,11 @@ public readonly struct RelativePath : IPath, IEquatable, IComparab public override int GetHashCode() { - return Parts.Aggregate(0, + if (_hashCode != 0) return _hashCode; + + _hashCode = Parts.Aggregate(0, (current, part) => current ^ part.GetHashCode(StringComparison.CurrentCultureIgnoreCase)); + return _hashCode; } public bool Equals(RelativePath other)