diff --git a/DepotDownloader/ProtoManifest.cs b/DepotDownloader/ProtoManifest.cs index 70389a0..1770cb5 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 40adc9d..b1495fe 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 9dd954c..eccca48 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();