Skip to content

Commit

Permalink
Workaround stale cache of CM servers
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Oct 14, 2024
1 parent fc64511 commit 5a9750a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
20 changes: 3 additions & 17 deletions ArchiSteamFarm/Core/ASF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
using ArchiSteamFarm.Web.Responses;
using JetBrains.Annotations;
using SteamKit2;
using SteamKit2.Discovery;

namespace ArchiSteamFarm.Core;

Expand Down Expand Up @@ -676,22 +675,9 @@ private static async Task RegisterBots() {
throw new InvalidOperationException(nameof(WebBrowser));
}

// Ensure that we ask for a list of servers if we don't have any saved servers available
IEnumerable<ServerRecord> servers = await GlobalDatabase.ServerListProvider.FetchServerListAsync().ConfigureAwait(false);

if (!servers.Any()) {
ArchiLogger.LogGenericInfo(Strings.FormatInitializing(nameof(SteamDirectory)));

SteamConfiguration steamConfiguration = SteamConfiguration.Create(static builder => builder.WithProtocolTypes(GlobalConfig.SteamProtocols).WithCellID(GlobalDatabase.CellID).WithServerListProvider(GlobalDatabase.ServerListProvider).WithHttpClientFactory(static () => WebBrowser.GenerateDisposableHttpClient()));

try {
await SteamDirectory.LoadAsync(steamConfiguration).ConfigureAwait(false);
ArchiLogger.LogGenericInfo(Strings.Success);
} catch (Exception e) {
ArchiLogger.LogGenericWarningException(e);
ArchiLogger.LogGenericWarning(Strings.BotSteamDirectoryInitializationFailed);
}
}
// Kill SK2 servers cache in order to force refresh during initial connection
// TODO: This should be removed when SK2 learns to purge its stale cache itself
await GlobalDatabase.ServerListProvider.UpdateServerListAsync([]).ConfigureAwait(false);

HashSet<string> botNames;

Expand Down
3 changes: 0 additions & 3 deletions ArchiSteamFarm/Localization/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,6 @@ StackTrace:
<data name="BotHeartBeatFailed" xml:space="preserve">
<value>Failed to disconnect the client. Abandoning this bot instance!</value>
</data>
<data name="BotSteamDirectoryInitializationFailed" xml:space="preserve">
<value>Could not initialize SteamDirectory: connecting with Steam Network might take much longer than usual!</value>
</data>
<data name="BotStopping" xml:space="preserve">
<value>Stopping...</value>
</data>
Expand Down

0 comments on commit 5a9750a

Please sign in to comment.