mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2025-07-25 04:43:58 +00:00
Fix nullable reference logic errors.
This commit is contained in:
@ -171,10 +171,6 @@ namespace Wabbajack.BuildServer.Models.Jobs
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var gameMeta = state.Game.MetaData();
|
var gameMeta = state.Game.MetaData();
|
||||||
if (gameMeta == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var game = gameMeta.Game;
|
|
||||||
|
|
||||||
var modFiles = (await db.NexusModFiles.AsQueryable().Where(g => g.Game == gameMeta.NexusName && g.ModId == state.ModID).FirstOrDefaultAsync())?.Data;
|
var modFiles = (await db.NexusModFiles.AsQueryable().Where(g => g.Game == gameMeta.NexusName && g.ModId == state.ModID).FirstOrDefaultAsync())?.Data;
|
||||||
|
|
||||||
@ -182,7 +178,7 @@ namespace Wabbajack.BuildServer.Models.Jobs
|
|||||||
{
|
{
|
||||||
Utils.Log($"No Cache for {state.PrimaryKeyString} falling back to HTTP");
|
Utils.Log($"No Cache for {state.PrimaryKeyString} falling back to HTTP");
|
||||||
var nexusApi = await NexusApiClient.Get();
|
var nexusApi = await NexusApiClient.Get();
|
||||||
modFiles = await nexusApi.GetModFiles(game, state.ModID);
|
modFiles = await nexusApi.GetModFiles(state.Game, state.ModID);
|
||||||
}
|
}
|
||||||
|
|
||||||
var found = modFiles.files
|
var found = modFiles.files
|
||||||
|
@ -36,7 +36,7 @@ namespace Wabbajack.Common
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, [MaybeNullWhen(false)] out object result)
|
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, [MaybeNullWhen(false)] out object? result)
|
||||||
{
|
{
|
||||||
if (indexes.Length > 1)
|
if (indexes.Length > 1)
|
||||||
{
|
{
|
||||||
@ -115,7 +115,7 @@ namespace Wabbajack.Common
|
|||||||
return Encoding.UTF8.GetString(acc.ToArray());
|
return Encoding.UTF8.GetString(acc.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, [MaybeNullWhen(false)] out object result)
|
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, [MaybeNullWhen(false)] out object? result)
|
||||||
{
|
{
|
||||||
if (indexes.Length > 1)
|
if (indexes.Length > 1)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@ -690,10 +691,16 @@ namespace Wabbajack.Common
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Join("|", Paths.Select(t => t.ToString()).Cons(BaseHash.ToString()));
|
var paths = Paths == null ? EmptyPath : Paths;
|
||||||
|
return string.Join("|", paths.Select(t => t.ToString()).Cons(BaseHash.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static RelativePath[] EmptyPath = Array.Empty<RelativePath>();
|
||||||
|
|
||||||
public static bool operator ==(HashRelativePath a, HashRelativePath b)
|
public static bool operator ==(HashRelativePath a, HashRelativePath b)
|
||||||
{
|
{
|
||||||
|
if (a.Paths == null || b.Paths == null) return false;
|
||||||
|
|
||||||
if (a.BaseHash != b.BaseHash || a.Paths.Length != b.Paths.Length)
|
if (a.BaseHash != b.BaseHash || a.Paths.Length != b.Paths.Length)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -739,6 +746,7 @@ namespace Wabbajack.Common
|
|||||||
public struct FullPath : IEquatable<FullPath>, IPath
|
public struct FullPath : IEquatable<FullPath>, IPath
|
||||||
{
|
{
|
||||||
public AbsolutePath Base { get; }
|
public AbsolutePath Base { get; }
|
||||||
|
|
||||||
public RelativePath[] Paths { get; }
|
public RelativePath[] Paths { get; }
|
||||||
|
|
||||||
private readonly int _hash;
|
private readonly int _hash;
|
||||||
@ -746,7 +754,7 @@ namespace Wabbajack.Common
|
|||||||
public FullPath(AbsolutePath basePath, params RelativePath[] paths)
|
public FullPath(AbsolutePath basePath, params RelativePath[] paths)
|
||||||
{
|
{
|
||||||
Base = basePath;
|
Base = basePath;
|
||||||
Paths = paths;
|
Paths = paths == null ? Array.Empty<RelativePath>() : paths;
|
||||||
_hash = Base.GetHashCode();
|
_hash = Base.GetHashCode();
|
||||||
foreach (var itm in Paths)
|
foreach (var itm in Paths)
|
||||||
{
|
{
|
||||||
@ -756,7 +764,8 @@ namespace Wabbajack.Common
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Join("|", Paths.Select(t => (string)t).Cons((string)Base));
|
var paths = Paths == null ? EmptyPath : Paths;
|
||||||
|
return string.Join("|", paths.Select(t => (string)t).Cons((string)Base));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
@ -764,8 +773,12 @@ namespace Wabbajack.Common
|
|||||||
return _hash;
|
return _hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static RelativePath[] EmptyPath = Array.Empty<RelativePath>();
|
||||||
|
|
||||||
public static bool operator ==(FullPath a, FullPath b)
|
public static bool operator ==(FullPath a, FullPath b)
|
||||||
{
|
{
|
||||||
|
if (a.Paths == null || b.Paths == null) return false;
|
||||||
|
|
||||||
if (a.Base != b.Base || a.Paths.Length != b.Paths.Length)
|
if (a.Base != b.Base || a.Paths.Length != b.Paths.Length)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -780,7 +780,7 @@ namespace Wabbajack.Common
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ePatch = null;
|
ePatch = Array.Empty<byte>();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,9 +94,7 @@ namespace Wabbajack.Lib.CompilationSteps
|
|||||||
e.To = source.Path;
|
e.To = source.Path;
|
||||||
e.Hash = source.File.Hash;
|
e.Hash = source.File.Hash;
|
||||||
|
|
||||||
Utils.TryGetPatch(found.Hash, source.File.Hash, out var data);
|
if (Utils.TryGetPatch(found.Hash, source.File.Hash, out var data))
|
||||||
|
|
||||||
if (data != null)
|
|
||||||
e.PatchID = await _compiler.IncludeFile(data);
|
e.PatchID = await _compiler.IncludeFile(data);
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
|
@ -450,12 +450,11 @@ namespace Wabbajack.Lib
|
|||||||
private async Task BuildArchivePatches(Hash archiveSha, IEnumerable<PatchedFromArchive> group,
|
private async Task BuildArchivePatches(Hash archiveSha, IEnumerable<PatchedFromArchive> group,
|
||||||
Dictionary<RelativePath, AbsolutePath> absolutePaths)
|
Dictionary<RelativePath, AbsolutePath> absolutePaths)
|
||||||
{
|
{
|
||||||
using (var files = await VFS.StageWith(group.Select(g => VFS.Index.FileForArchiveHashPath(g.ArchiveHashPath))))
|
using var files = await VFS.StageWith(@group.Select(g => VFS.Index.FileForArchiveHashPath(g.ArchiveHashPath)));
|
||||||
{
|
|
||||||
var byPath = 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());
|
.ToDictionary(f => f.Key, f => f.First());
|
||||||
// Now Create the patches
|
// Now Create the patches
|
||||||
await group.PMap(Queue, async entry =>
|
await @group.PMap(Queue, async entry =>
|
||||||
{
|
{
|
||||||
Info($"Patching {entry.To}");
|
Info($"Patching {entry.To}");
|
||||||
Status($"Patching {entry.To}");
|
Status($"Patching {entry.To}");
|
||||||
@ -468,7 +467,6 @@ namespace Wabbajack.Lib
|
|||||||
Info($"Patch size {outputStream.Length} for {entry.To}");
|
Info($"Patch size {outputStream.Length} for {entry.To}");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private FileStream LoadDataForTo(RelativePath to, Dictionary<RelativePath, AbsolutePath> absolutePaths)
|
private FileStream LoadDataForTo(RelativePath to, Dictionary<RelativePath, AbsolutePath> absolutePaths)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user