mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix Wabbajack.Lib
This commit is contained in:
parent
03a68da0d1
commit
131f7de823
@ -338,11 +338,18 @@ namespace Wabbajack.Lib
|
||||
}
|
||||
}
|
||||
|
||||
Utils.Log("Exporting ModList metadata");
|
||||
Utils.Log("Exporting Modlist metadata");
|
||||
var outputFileHash = await ModListOutputFile.FileHashAsync();
|
||||
if (outputFileHash == null)
|
||||
{
|
||||
Utils.Error("Unable to hash Modlist Output File");
|
||||
return;
|
||||
}
|
||||
|
||||
var metadata = new DownloadMetadata
|
||||
{
|
||||
Size = ModListOutputFile.Size,
|
||||
Hash = await ModListOutputFile.FileHashAsync(),
|
||||
Hash = outputFileHash.Value,
|
||||
NumberOfArchives = ModList.Archives.Count,
|
||||
SizeOfArchives = ModList.Archives.Sum(a => a.Size),
|
||||
NumberOfInstalledFiles = ModList.Directives.Count,
|
||||
|
@ -145,7 +145,7 @@ namespace Wabbajack.Lib
|
||||
await ClientAPI.GetVirusScanResult(toFile) == VirusScanner.Result.Malware)
|
||||
{
|
||||
await toFile.DeleteAsync();
|
||||
Utils.ErrorThrow(new Exception($"Virus scan of patched executable reported possible malware: {toFile.ToString()} ({(long)await toFile.FileHashCachedAsync()})"));
|
||||
Utils.ErrorThrow(new Exception($"Virus scan of patched executable reported possible malware: {toFile.ToString()} ({(long)(await toFile.FileHashCachedAsync())!.Value})"));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -298,7 +298,8 @@ namespace Wabbajack.Lib
|
||||
.OrderByDescending(e => e.Item2.LastModified)
|
||||
.GroupBy(e => e.Item1)
|
||||
.Select(e => e.First())
|
||||
.Select(e => new KeyValuePair<Hash, AbsolutePath>(e.Item1, e.Item2)));
|
||||
.Where(x => x.Item1 != null)
|
||||
.Select(e => new KeyValuePair<Hash, AbsolutePath>(e.Item1!.Value, e.Item2)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -58,7 +58,7 @@ namespace Wabbajack.Lib.AuthorApi
|
||||
{
|
||||
OriginalFileName = path.FileName,
|
||||
Size = path.Size,
|
||||
Hash = await path.FileHashCachedAsync(),
|
||||
Hash = await path.FileHashCachedAsync() ?? Hash.Empty,
|
||||
Parts = await parts.PMap(queue, async part =>
|
||||
{
|
||||
progressFn("Hashing file parts", Percent.FactoryPutInRange(part.Index, parts.Length));
|
||||
|
@ -242,8 +242,12 @@ using Wabbajack.Lib.Downloaders;
|
||||
Utils.Log($"Checking virus result for {path}");
|
||||
|
||||
var hash = await path.FileHashAsync();
|
||||
if (hash == null)
|
||||
{
|
||||
throw new Exception("Hash is null!");
|
||||
}
|
||||
|
||||
using var result = await client.GetAsync($"{Consts.WabbajackBuildServerUri}virus_scan/{hash.ToHex()}", errorsAsExceptions: false);
|
||||
using var result = await client.GetAsync($"{Consts.WabbajackBuildServerUri}virus_scan/{hash.Value.ToHex()}", errorsAsExceptions: false);
|
||||
if (result.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
var data = await result.Content.ReadAsStringAsync();
|
||||
|
@ -334,14 +334,15 @@ namespace Wabbajack.Lib.Downloaders
|
||||
if (await newFile.State.Download(newFile, tmp.Path))
|
||||
{
|
||||
newFile.Size = tmp.Path.Size;
|
||||
newFile.Hash = await tmp.Path.FileHashAsync();
|
||||
var tmpHash = await tmp.Path.FileHashAsync();
|
||||
if (tmpHash == null) return default;
|
||||
newFile.Hash = tmpHash.Value;
|
||||
return (newFile, tmp);
|
||||
}
|
||||
|
||||
await tmp.DisposeAsync();
|
||||
}
|
||||
return default;
|
||||
|
||||
}
|
||||
|
||||
public override async Task<bool> ValidateUpgrade(Hash srcHash, AbstractDownloadState newArchiveState)
|
||||
|
@ -28,12 +28,13 @@ namespace Wabbajack.Lib.Downloaders
|
||||
|
||||
var fp = filePath.Value;
|
||||
var hash = await fp.FileHashCachedAsync();
|
||||
if (hash == null) return null;
|
||||
|
||||
return new State(game.InstalledVersion)
|
||||
{
|
||||
Game = game.Game,
|
||||
GameFile = (RelativePath)gameFile,
|
||||
Hash = hash
|
||||
Hash = hash.Value
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,9 @@ TOP:
|
||||
return default;
|
||||
}
|
||||
|
||||
newArchive.Hash = await tmpFile.Path.FileHashAsync();
|
||||
var hash = await tmpFile.Path.FileHashAsync();
|
||||
if (hash == null) return default;
|
||||
newArchive.Hash = hash.Value;
|
||||
newArchive.Size = tmpFile.Path.Size;
|
||||
|
||||
if (newArchive.Hash == a.Hash || a.Size > 2_500_000_000 || newArchive.Size > 2_500_000_000)
|
||||
|
@ -290,7 +290,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
if (fastPath != default)
|
||||
{
|
||||
newArchive.Size = fastPath.Size;
|
||||
newArchive.Hash = await fastPath.FileHashAsync();
|
||||
var hash = await fastPath.FileHashAsync();
|
||||
if (hash == null) return default;
|
||||
newArchive.Hash = hash.Value;
|
||||
return (newArchive, new TempFile());
|
||||
}
|
||||
|
||||
@ -300,7 +302,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
await newArchive.State.Download(newArchive, tempFile.Path);
|
||||
|
||||
newArchive.Size = tempFile.Path.Size;
|
||||
newArchive.Hash = await tempFile.Path.FileHashAsync();
|
||||
var newArchiveHash = await tempFile.Path.FileHashAsync();
|
||||
if (newArchiveHash == null) return default;
|
||||
newArchive.Hash = newArchiveHash.Value;
|
||||
|
||||
Utils.Log($"Possible upgrade {newArchive.State.PrimaryKeyString} downloaded");
|
||||
|
||||
|
@ -382,11 +382,15 @@ namespace Wabbajack.Lib
|
||||
var source = DownloadsPath.Combine(a.Name + Consts.MetaFileExtension);
|
||||
var ini = a.State.GetMetaIniString();
|
||||
var (id, fullPath) = await IncludeString(ini);
|
||||
var hash = await fullPath.FileHashAsync();
|
||||
|
||||
if (hash == null) return;
|
||||
|
||||
InstallDirectives.Add(new ArchiveMeta
|
||||
{
|
||||
SourceDataID = id,
|
||||
Size = fullPath.Size,
|
||||
Hash = await fullPath.FileHashAsync(),
|
||||
Hash = hash.Value,
|
||||
To = source.FileName
|
||||
});
|
||||
});
|
||||
|
@ -294,7 +294,7 @@ namespace Wabbajack.Lib
|
||||
var hash = await gameFile.FileHashAsync();
|
||||
if (hash != esm.SourceESMHash)
|
||||
{
|
||||
Utils.ErrorThrow(new InvalidGameESMError(esm, hash, gameFile));
|
||||
Utils.ErrorThrow(new InvalidGameESMError(esm, hash ?? Hash.Empty, gameFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return DownloadMetadata.Hash != await modlistPath.FileHashCachedAsync(true);
|
||||
return DownloadMetadata.Hash != await modlistPath.FileHashCachedAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user