mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #1095 from wabbajack-tools/fallback-on-bad-hash
tweaks to downloads and compilation
This commit is contained in:
commit
d087b434d6
@ -9,6 +9,7 @@ This is now the only way to include extra games in the install process, implicit
|
|||||||
* Includes a "Favor performance over RAM" optional mode (defaults to off) that will use excessive amounts of RAM in exchange
|
* Includes a "Favor performance over RAM" optional mode (defaults to off) that will use excessive amounts of RAM in exchange
|
||||||
for almost 1GB/sec install speed on the correct hardware. Don't enable this unless you have a fast SSD and at least 2.5GB of RAM for every
|
for almost 1GB/sec install speed on the correct hardware. Don't enable this unless you have a fast SSD and at least 2.5GB of RAM for every
|
||||||
install thread.
|
install thread.
|
||||||
|
* If a downloaded file doesn't match the expected hash, try alternative download locations, if allowed
|
||||||
|
|
||||||
|
|
||||||
#### Version - 2.2.2.0 - 8/31/2020
|
#### Version - 2.2.2.0 - 8/31/2020
|
||||||
|
@ -104,8 +104,9 @@ namespace Wabbajack.Lib.Downloaders
|
|||||||
{
|
{
|
||||||
if (await Download(archive, destination))
|
if (await Download(archive, destination))
|
||||||
{
|
{
|
||||||
await destination.FileHashCachedAsync();
|
var downloadedHash = await destination.FileHashCachedAsync();
|
||||||
return DownloadResult.Success;
|
if (downloadedHash == archive.Hash || archive.Hash == default)
|
||||||
|
return DownloadResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +26,19 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
Definitions.FileType._7Z);
|
Definitions.FileType._7Z);
|
||||||
|
|
||||||
private static Extension OMODExtension = new Extension(".omod");
|
private static Extension OMODExtension = new Extension(".omod");
|
||||||
|
private static Extension BSAExtension = new Extension(".bsa");
|
||||||
|
|
||||||
|
public static readonly HashSet<Extension> ExtractableExtensions = new HashSet<Extension>
|
||||||
|
{
|
||||||
|
new Extension(".bsa"),
|
||||||
|
new Extension(".ba2"),
|
||||||
|
new Extension(".7z"),
|
||||||
|
new Extension(".7zip"),
|
||||||
|
new Extension(".rar"),
|
||||||
|
new Extension(".zip"),
|
||||||
|
OMODExtension
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When true, will allow 7z to use multiple threads and cache more data in memory, potentially
|
/// When true, will allow 7z to use multiple threads and cache more data in memory, potentially
|
||||||
@ -64,11 +77,16 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case Definitions.FileType.TES3:
|
|
||||||
case Definitions.FileType.BSA:
|
case Definitions.FileType.BSA:
|
||||||
case Definitions.FileType.BA2:
|
case Definitions.FileType.BA2:
|
||||||
return await GatheringExtractWithBSA(sFn, (Definitions.FileType)sig, shouldExtract, mapfn);
|
return await GatheringExtractWithBSA(sFn, (Definitions.FileType)sig, shouldExtract, mapfn);
|
||||||
|
|
||||||
|
case Definitions.FileType.TES3:
|
||||||
|
if (sFn.Name.FileName.Extension == BSAExtension)
|
||||||
|
return await GatheringExtractWithBSA(sFn, (Definitions.FileType)sig, shouldExtract, mapfn);
|
||||||
|
else
|
||||||
|
throw new Exception($"Invalid file format {sFn.Name}");
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Exception($"Invalid file format {sFn.Name}");
|
throw new Exception($"Invalid file format {sFn.Name}");
|
||||||
|
@ -177,16 +177,27 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
public static async Task<VirtualFile> Analyze(Context context, VirtualFile parent, IStreamFactory extractedFile,
|
public static async Task<VirtualFile> Analyze(Context context, VirtualFile parent, IStreamFactory extractedFile,
|
||||||
IPath relPath, int depth = 0)
|
IPath relPath, int depth = 0)
|
||||||
{
|
{
|
||||||
await using var stream = await extractedFile.GetStream();
|
Hash hash = default;
|
||||||
var hash = await stream.xxHashAsync();
|
if (extractedFile is NativeFileStreamFactory)
|
||||||
stream.Position = 0;
|
{
|
||||||
|
hash = await ((AbsolutePath)extractedFile.Name).FileHashCachedAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await using var hstream = await extractedFile.GetStream();
|
||||||
|
hash = await hstream.xxHashAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TryGetFromCache(context, parent, relPath, extractedFile, hash, out var vself))
|
||||||
|
{
|
||||||
|
return vself;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
await using var stream = await extractedFile.GetStream();
|
||||||
var sig = await FileExtractor2.ArchiveSigs.MatchesAsync(stream);
|
var sig = await FileExtractor2.ArchiveSigs.MatchesAsync(stream);
|
||||||
stream.Position = 0;
|
stream.Position = 0;
|
||||||
|
|
||||||
if (sig.HasValue && TryGetFromCache(context, parent, relPath, extractedFile, hash, out var vself))
|
|
||||||
return vself;
|
|
||||||
|
|
||||||
var self = new VirtualFile
|
var self = new VirtualFile
|
||||||
{
|
{
|
||||||
Context = context,
|
Context = context,
|
||||||
@ -204,7 +215,7 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
self.ExtendedHashes = await ExtendedHashes.FromStream(stream);
|
self.ExtendedHashes = await ExtendedHashes.FromStream(stream);
|
||||||
|
|
||||||
// Can't extract, so return
|
// Can't extract, so return
|
||||||
if (!sig.HasValue) return self;
|
if (!sig.HasValue || !FileExtractor2.ExtractableExtensions.Contains(relPath.FileName.Extension)) return self;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user