Fix Wabbajack.CLI

This commit is contained in:
erri120 2021-01-09 19:44:59 +01:00
parent 37683d73a5
commit 9d79aa7381
4 changed files with 21 additions and 7 deletions

View File

@ -139,6 +139,8 @@ namespace Wabbajack.CLI.Verbs
CLIUtils.Log($"Hashing {f}");
return (f, await f.FileHashCachedAsync());
}))
.Where(x => x.Item2.HasValue)
.Select(x => (x.f, x.Item2!.Value))
.GroupBy(d => d.Item2)
.ToDictionary(d => d.Key, d => d.First().f);

View File

@ -28,8 +28,14 @@ namespace Wabbajack.CLI.Verbs
var oldHash = await Old.FileHashCachedAsync();
var newHash = await New.FileHashCachedAsync();
var oldArchive = new Archive(oldState) {Hash = oldHash, Size = Old.Size};
var newArchive = new Archive(newState) {Hash = newHash, Size = New.Size};
if (oldHash == null)
return ExitCode.Error;
if (newHash == null)
return ExitCode.Error;
var oldArchive = new Archive(oldState) {Hash = oldHash!.Value, Size = Old.Size};
var newArchive = new Archive(newState) {Hash = newHash!.Value, Size = New.Size};
Utils.Log($"Contacting Server to request patch ({oldHash} -> {newHash}");
Utils.Log($"Response: {await ClientAPI.GetModUpgrade(oldArchive, newArchive, useAuthor: true)}");

View File

@ -16,7 +16,12 @@ namespace Wabbajack.CLI.Verbs
{
var abs = (AbsolutePath)Input;
var hash = await abs.FileHashAsync();
Console.WriteLine($"{abs} hash: {hash} {hash.ToHex()} {(long)hash}");
if (hash == null)
{
Console.WriteLine("Hash is null!");
return ExitCode.Error;
}
Console.WriteLine($"{abs} hash: {hash} {hash.Value.ToHex()} {(long)hash}");
return ExitCode.Ok;
}
}

View File

@ -31,25 +31,26 @@ namespace Wabbajack.CLI.Verbs
Utils.Log($"Hashing files for {_game} {version}");
var indexed = await gameLocation
var indexed = (await gameLocation
.EnumerateFiles()
.PMap(queue, async f =>
{
var hash = await f.FileHashCachedAsync();
if (hash == null) return null;
return new Archive(new GameFileSourceDownloader.State
{
Game = _game,
GameFile = f.RelativeTo(gameLocation),
Hash = hash,
Hash = hash.Value,
GameVersion = version
})
{
Name = f.FileName.ToString(),
Hash = hash,
Hash = hash.Value,
Size = f.Size
};
});
})).NotNull().ToArray();
Utils.Log($"Found and hashed {indexed.Length} files");
await indexed.ToJsonAsync(file, prettyPrint: true);