From 69707095cd485758e7cc2fc6e5ab4ae2d908509f Mon Sep 17 00:00:00 2001 From: Antoine Rybacki <15911822+Lifeismana@users.noreply.github.com> Date: Sat, 18 Nov 2023 11:38:26 +0100 Subject: [PATCH] address feedback --- DepotDownloader/ProtoManifest.cs | 7 ++++--- DepotDownloader/Steam3Session.cs | 10 ++++++++-- DepotDownloader/Util.cs | 10 +--------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/DepotDownloader/ProtoManifest.cs b/DepotDownloader/ProtoManifest.cs index 70389a05..1770cb50 100644 --- a/DepotDownloader/ProtoManifest.cs +++ b/DepotDownloader/ProtoManifest.cs @@ -1,7 +1,8 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.IO.Compression; +using System.Security.Cryptography; using ProtoBuf; using SteamKit2; @@ -135,7 +136,7 @@ namespace DepotDownloader using (var ds = new DeflateStream(fs, CompressionMode.Decompress)) ds.CopyTo(ms); - checksum = Util.SHAHash(ms.ToArray()); + checksum = SHA1.HashData(ms.ToArray()); ms.Seek(0, SeekOrigin.Begin); return Serializer.Deserialize(ms); @@ -148,7 +149,7 @@ namespace DepotDownloader { Serializer.Serialize(ms, this); - checksum = Util.SHAHash(ms.ToArray()); + checksum = SHA1.HashData(ms.ToArray()); ms.Seek(0, SeekOrigin.Begin); diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index 40adc9da..b1495fe7 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -560,8 +560,14 @@ namespace DepotDownloader logonDetails.Password = null; logonDetails.AccessToken = result.RefreshToken; - // Should i check if guardData is null ? - AccountSettingsStore.Instance.GuardData[result.AccountName] = result.NewGuardData; + if (result.NewGuardData != null) + { + AccountSettingsStore.Instance.GuardData[result.AccountName] = result.NewGuardData; + } + else + { + AccountSettingsStore.Instance.GuardData.Remove(result.AccountName); + } AccountSettingsStore.Instance.LoginTokens[result.AccountName] = result.RefreshToken; AccountSettingsStore.Save(); } diff --git a/DepotDownloader/Util.cs b/DepotDownloader/Util.cs index 9dd954ce..eccca488 100644 --- a/DepotDownloader/Util.cs +++ b/DepotDownloader/Util.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; @@ -113,13 +112,6 @@ namespace DepotDownloader return BitConverter.GetBytes(a | (b << 16)); } - public static byte[] SHAHash(byte[] input) - { - var output = SHA1.HashData(input); - - return output; - } - public static byte[] DecodeHexString(string hex) { if (hex == null) @@ -144,7 +136,7 @@ namespace DepotDownloader public static async Task InvokeAsync(IEnumerable> taskFactories, int maxDegreeOfParallelism) { ArgumentNullException.ThrowIfNull(taskFactories); - if (maxDegreeOfParallelism <= 0) throw new ArgumentException(nameof(maxDegreeOfParallelism)); + ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(0, maxDegreeOfParallelism); var queue = taskFactories.ToArray();