diff --git a/DepotDownloader/CDNClientPool.cs b/DepotDownloader/CDNClientPool.cs index 4b03c89b..be45e167 100644 --- a/DepotDownloader/CDNClientPool.cs +++ b/DepotDownloader/CDNClientPool.cs @@ -134,10 +134,10 @@ namespace DepotDownloader { steamSession.RequestCDNAuthToken(appId, depotId, server.Host); - var cdnTuple = Tuple.Create(depotId, server.Host); + var cdnKey = string.Format("{0:D}:{1}", depotId, server.Host); SteamApps.CDNAuthTokenCallback authTokenCallback; - if (steamSession.CDNAuthTokens.TryGetValue(cdnTuple, out authTokenCallback)) + if (steamSession.CDNAuthTokens.TryGetValue(cdnKey, out authTokenCallback)) { cdnAuthToken = authTokenCallback.Token; } @@ -180,10 +180,10 @@ namespace DepotDownloader { steamSession.RequestCDNAuthToken(appId, depotId, server.Host); - var cdnTuple = Tuple.Create(depotId, server.Host); + var cdnKey = string.Format("{0:D}:{1}", depotId, server.Host); SteamApps.CDNAuthTokenCallback authTokenCallback; - if (steamSession.CDNAuthTokens.TryGetValue(cdnTuple, out authTokenCallback)) + if (steamSession.CDNAuthTokens.TryGetValue(cdnKey, out authTokenCallback)) { cdnAuthToken = authTokenCallback.Token; } diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index 832e959c..fc10ad4c 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -1,5 +1,6 @@ using SteamKit2; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; @@ -30,7 +31,7 @@ namespace DepotDownloader public Dictionary AppTickets { get; private set; } public Dictionary AppTokens { get; private set; } public Dictionary DepotKeys { get; private set; } - public Dictionary, SteamApps.CDNAuthTokenCallback> CDNAuthTokens { get; private set; } + public ConcurrentDictionary CDNAuthTokens { get; private set; } public Dictionary AppInfo { get; private set; } public Dictionary PackageInfo { get; private set; } public Dictionary AppBetaPasswords { get; private set; } @@ -71,7 +72,7 @@ namespace DepotDownloader this.AppTickets = new Dictionary(); this.AppTokens = new Dictionary(); this.DepotKeys = new Dictionary(); - this.CDNAuthTokens = new Dictionary, SteamApps.CDNAuthTokenCallback>(); + this.CDNAuthTokens = new ConcurrentDictionary(); this.AppInfo = new Dictionary(); this.PackageInfo = new Dictionary(); this.AppBetaPasswords = new Dictionary(); @@ -287,7 +288,9 @@ namespace DepotDownloader public void RequestCDNAuthToken(uint appid, uint depotid, string host) { - if (CDNAuthTokens.ContainsKey(Tuple.Create(depotid, host)) || bAborted) + var cdnKey = string.Format("{0:D}:{1}", depotid, host); + + if (CDNAuthTokens.ContainsKey(cdnKey) || bAborted) return; bool completed = false; @@ -302,7 +305,7 @@ namespace DepotDownloader return; } - CDNAuthTokens[Tuple.Create(depotid, host)] = cdnAuth; + CDNAuthTokens.TryAdd(cdnKey, cdnAuth); }; WaitUntilCallback(() =>