diff --git a/CHANGELOG.md b/CHANGELOG.md index fbf3b1cf..c7f51ae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ #### Version - 2.2.1.6 - 8/21/2020 * HOTFIX - Make LoversLab auto-update work again +* HOTFIX - Fix for "End of Stream before End of Limit" symptom on BSA extraction #### Version - 2.2.1.5 - 8/21/2020 * HOTFIX - Fix for broken patching in RGE and other lists diff --git a/Compression.BSA.Test/BSATests.cs b/Compression.BSA.Test/BSATests.cs index ecf14c9d..c47ed51d 100644 --- a/Compression.BSA.Test/BSATests.cs +++ b/Compression.BSA.Test/BSATests.cs @@ -72,6 +72,7 @@ namespace Compression.BSA.Test [InlineData(Game.SkyrimSpecialEdition, 12604)] // SkyUI [InlineData(Game.Skyrim, 3863)] // SkyUI [InlineData(Game.Skyrim, 51473)] // INeed + [InlineData(Game.Skyrim, 41634)] // DVA [InlineData(Game.Fallout4, 22223)] // 10mm SMG [InlineData(Game.Fallout4, 4472)] // True Storms [InlineData(Game.Morrowind, 44537)] diff --git a/Compression.BSA/BSA/Reader/FileRecord.cs b/Compression.BSA/BSA/Reader/FileRecord.cs index d6e2b7bf..fcfc2dab 100644 --- a/Compression.BSA/BSA/Reader/FileRecord.cs +++ b/Compression.BSA/BSA/Reader/FileRecord.cs @@ -129,6 +129,8 @@ namespace Compression.BSA nameBlobOffset = rdr.ReadByte(); // Just skip, not using rdr.BaseStream.Position += nameBlobOffset; + // Minus one more for the size of the name blob offset size + nameBlobOffset++; } else { diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index 57fc643c..a9df9d68 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -1030,6 +1030,7 @@ namespace Wabbajack.Common public static async Task CopyToLimitAsync(this Stream frm, Stream tw, long limit) { var buff = new byte[1024]; + var initalLimit = limit; while (limit > 0) { var to_read = Math.Min(buff.Length, limit); diff --git a/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs b/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs index 8f567f2e..d1b19d93 100644 --- a/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs +++ b/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs @@ -155,7 +155,7 @@ namespace Wabbajack.Lib.Downloaders } else { - var csrfURL = FileID == null + var csrfURL = string.IsNullOrWhiteSpace(FileID) ? $"{Site}/files/file/{FileName}/?do=download" : $"{Site}/files/file/{FileName}/?do=download&r={FileID}"; var html = await Downloader.AuthedClient.GetStringAsync(csrfURL); @@ -166,7 +166,10 @@ namespace Wabbajack.Lib.Downloaders var csrfKey = matches.Where(m => m.Length == 32).Select(m => m.ToString()).FirstOrDefault(); if (csrfKey == null) + { + Utils.Log($"Returning null from IPS4 Downloader because no csrfKey was found"); return null; + } var sep = Site.EndsWith("?") ? "&" : "?"; url = FileID == null @@ -193,10 +196,12 @@ namespace Wabbajack.Lib.Downloaders long.TryParse(headerVar, out headerContentSize); } - - if (a.Size != 0 && headerContentSize != 0 && a.Size != headerContentSize) + if (a.Size != 0 && headerContentSize != 0 && a.Size != headerContentSize) + { + Utils.Log($"Bad Header Content sizes {a.Size} vs {headerContentSize}"); return null; - + } + return streamResult; } @@ -261,6 +266,11 @@ namespace Wabbajack.Lib.Downloaders } + public override async Task ValidateUpgrade(Hash srcHash, AbstractDownloadState newArchiveState) + { + return !string.IsNullOrWhiteSpace(FileID); + } + public async Task> GetFilesInGroup() { var others = await Downloader.AuthedClient.GetHtmlAsync($"{Site}/files/file/{FileName}?do=download"); diff --git a/Wabbajack.Server/DataLayer/Patches.cs b/Wabbajack.Server/DataLayer/Patches.cs index 7cae5508..f46597f3 100644 --- a/Wabbajack.Server/DataLayer/Patches.cs +++ b/Wabbajack.Server/DataLayer/Patches.cs @@ -207,7 +207,8 @@ namespace Wabbajack.Server.DataLayer return (await conn.QueryAsync<(Hash, Hash)>(@"SELECT a1.Hash, a2.Hash FROM dbo.Patches p LEFT JOIN dbo.ArchiveDownloads a1 ON a1.Id = p.SrcId - LEFT JOIN dbo.ArchiveDownloads a2 on a2.Id = p.DestId")).ToHashSet(); + LEFT JOIN dbo.ArchiveDownloads a2 on a2.Id = p.DestId + WHERE p.Finished IS NOT NULL")).ToHashSet(); } public async Task DeletePatchesForHashPair((Hash, Hash) sqlFile) diff --git a/Wabbajack.Server/Services/ArchiveDownloader.cs b/Wabbajack.Server/Services/ArchiveDownloader.cs index e64bedef..122df26b 100644 --- a/Wabbajack.Server/Services/ArchiveDownloader.cs +++ b/Wabbajack.Server/Services/ArchiveDownloader.cs @@ -68,7 +68,12 @@ namespace Wabbajack.Server.Services await DownloadDispatcher.PrepareAll(new[] {nextDownload.Archive.State}); await using var tempPath = new TempFile(); - await nextDownload.Archive.State.Download(nextDownload.Archive, tempPath.Path); + if (!await nextDownload.Archive.State.Download(nextDownload.Archive, tempPath.Path)) + { + _logger.LogError($"Downloader returned false for {nextDownload.Archive.State.PrimaryKeyString}"); + await nextDownload.Fail(_sql, "Downloader returned false"); + continue; + } var hash = await tempPath.Path.FileHashAsync();