From eb3e323971046bb914bf0de5e5f6e5860e5688a9 Mon Sep 17 00:00:00 2001 From: halgari Date: Sat, 15 Aug 2020 13:33:05 -0700 Subject: [PATCH] Fix endless loop in CopyToLimit --- Compression.BSA/Compression.BSA.csproj | 8 ++++---- Wabbajack.Common/CircuitBreaker/WithAutoRetry.cs | 6 +++--- Wabbajack.Common/Extensions/RxExt.cs | 2 +- Wabbajack.Common/FileSignatures/Signatures.tt | 1 - Wabbajack.Common/Utils.cs | 2 ++ Wabbajack.Common/Wabbajack.Common.csproj | 8 ++++---- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Compression.BSA/Compression.BSA.csproj b/Compression.BSA/Compression.BSA.csproj index 287f0911..0efee363 100644 --- a/Compression.BSA/Compression.BSA.csproj +++ b/Compression.BSA/Compression.BSA.csproj @@ -10,10 +10,10 @@ nullable true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - 2.2.1.1 - 2.2.1.1 - 2.2.1.1 - 2.2.1.1 + 2.2.1.2 + 2.2.1.2 + 2.2.1.2 + 2.2.1.2 Compression.BSA.xml diff --git a/Wabbajack.Common/CircuitBreaker/WithAutoRetry.cs b/Wabbajack.Common/CircuitBreaker/WithAutoRetry.cs index 50ca8501..a6c5587e 100644 --- a/Wabbajack.Common/CircuitBreaker/WithAutoRetry.cs +++ b/Wabbajack.Common/CircuitBreaker/WithAutoRetry.cs @@ -27,7 +27,7 @@ namespace Wabbajack.Common retries += 1; if (retries > maxRetries) throw; - Utils.Log($"(Retry {retries} of {maxRetries}), got exception {ex.Message}, waiting {delay.Value.TotalMilliseconds}ms"); + Utils.Log($"(Retry {retries} of {maxRetries}), got exception {ex.Message}, waiting {delay!.Value.TotalMilliseconds}ms"); await Task.Delay(delay.Value); delay = delay * multipler; goto TOP; @@ -51,7 +51,7 @@ namespace Wabbajack.Common retries += 1; if (retries > maxRetries) throw; - Utils.Log($"(Retry {retries} of {maxRetries}), got exception {ex.Message}, waiting {delay.Value.TotalMilliseconds}ms"); + Utils.Log($"(Retry {retries} of {maxRetries}), got exception {ex.Message}, waiting {delay!.Value.TotalMilliseconds}ms"); await Task.Delay(delay.Value); delay = delay * multipler; goto TOP; @@ -75,7 +75,7 @@ namespace Wabbajack.Common retries += 1; if (retries > maxRetries) throw; - Utils.Log($"(Retry {retries} of {maxRetries}), got exception {ex.Message}, waiting {delay.Value.TotalMilliseconds}ms"); + Utils.Log($"(Retry {retries} of {maxRetries}), got exception {ex.Message}, waiting {delay!.Value.TotalMilliseconds}ms"); Thread.Sleep(delay.Value); delay = delay * multipler; goto TOP; diff --git a/Wabbajack.Common/Extensions/RxExt.cs b/Wabbajack.Common/Extensions/RxExt.cs index 40d73602..76e0e758 100644 --- a/Wabbajack.Common/Extensions/RxExt.cs +++ b/Wabbajack.Common/Extensions/RxExt.cs @@ -108,7 +108,7 @@ namespace Wabbajack // We have another value that came in to fire. // Reregister for callback dueTimeDisposable.Disposable = scheduler.Schedule(interval, internalCallback); - o.OnNext(value); + o.OnNext(value!); value = default; hasValue = false; } diff --git a/Wabbajack.Common/FileSignatures/Signatures.tt b/Wabbajack.Common/FileSignatures/Signatures.tt index 5849108b..e273a80e 100644 --- a/Wabbajack.Common/FileSignatures/Signatures.tt +++ b/Wabbajack.Common/FileSignatures/Signatures.tt @@ -11,7 +11,6 @@ return Enumerable.Range(0, hex.Length) .Where(x => x % 2 == 0) .Select(x => Convert.ToByte(hex.Substring(x, 2), 16)) - .ToArray(); } var files = new string[] {"bsasigs.txt", "file_sigs_RAW.txt"}; diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index 4388eef2..57fc643c 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -1034,6 +1034,8 @@ namespace Wabbajack.Common { var to_read = Math.Min(buff.Length, limit); var read = await frm.ReadAsync(buff, 0, (int)to_read); + if (read == 0) + throw new Exception("End of stream before end of limit"); await tw.WriteAsync(buff, 0, read); limit -= read; } diff --git a/Wabbajack.Common/Wabbajack.Common.csproj b/Wabbajack.Common/Wabbajack.Common.csproj index 36d4e3fd..e88e48b2 100644 --- a/Wabbajack.Common/Wabbajack.Common.csproj +++ b/Wabbajack.Common/Wabbajack.Common.csproj @@ -14,10 +14,10 @@ https://www.wabbajack.org/favicon.ico https://github.com/wabbajack-tools/wabbajack $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - 2.2.1.1 - 2.2.1.1 - 2.2.1.1 - 2.2.1.1 + 2.2.1.2 + 2.2.1.2 + 2.2.1.2 + 2.2.1.2 Wabbajack.Common.xml