Skip to content

Commit

Permalink
Fix non-generic ASF crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Nov 27, 2024
1 parent b7e191e commit 7319145
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
9 changes: 3 additions & 6 deletions BoosterManager/Boosters/BoosterDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,9 @@ internal static BoosterDatabase CreateOrLoad(string filePath) {
}

internal void SetLastCraft(uint appID, DateTime craftTime) {
BoosterLastCraft newCraft = new BoosterLastCraft(craftTime);
BoosterLastCrafts.AddOrUpdate(appID, newCraft, (key, oldCraft) => {
oldCraft.CraftTime = craftTime;

return oldCraft;
});
if (!BoosterLastCrafts.TryAdd(appID, new BoosterLastCraft(craftTime))) {
BoosterLastCrafts[appID].CraftTime = craftTime;
}

Utilities.InBackground(Save);
}
Expand Down
2 changes: 1 addition & 1 deletion BoosterManager/Handlers/DataHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static async Task<string> SendMarketHistoryOnly(Bot bot, uint? numPages =
}

public static string StopSend(Bot bot) {
ForceStop.AddOrUpdate(bot.BotName, DateTime.Now, (_, _) => DateTime.Now);
ForceStop[bot.BotName] = DateTime.Now;

return Commands.FormatBotResponse(bot, ArchiSteamFarm.Localization.Strings.Success);
}
Expand Down
5 changes: 3 additions & 2 deletions BoosterManager/Handlers/StatusReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ internal void Report(Bot reportingBot, string report, bool suppressDuplicateMess
}
}

Reports.AddOrUpdate(reportingBot, new List<string>() { report }, (_, reports) => { reports.Add(report); return reports; });
Reports.TryAdd(reportingBot, new List<string>());
Reports[reportingBot].Add(report);

// I prefer to send all reports in as few messages as possible
// As long as reports continue to come in, we wait (until some limit, to avoid possibly waiting forever)
Expand Down Expand Up @@ -119,7 +120,7 @@ private async Task Send() {

if (Reports.TryRemove(bot, out List<string>? previousReports)) {
if (previousReports != null) {
PreviousReports.AddOrUpdate(bot, previousReports, (_, _) => previousReports);
PreviousReports[bot] = previousReports;
}
}
}
Expand Down

0 comments on commit 7319145

Please sign in to comment.