Skip to content

Commit

Permalink
Improve reliability when GlobalCache can't be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Nov 3, 2024
1 parent 1839f71 commit 69499d5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions FreePackages/Data/GlobalCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal GlobalCache() {

protected override Task Save() => Save(this);

internal static async Task<GlobalCache?> CreateOrLoad() {
internal static async Task<GlobalCache> CreateOrLoad() {
if (!File.Exists(SharedFilePath)) {
return new GlobalCache();
}
Expand All @@ -38,20 +38,20 @@ internal GlobalCache() {
if (string.IsNullOrEmpty(json)) {
ASF.ArchiLogger.LogGenericError(string.Format(ArchiSteamFarm.Localization.Strings.ErrorIsEmpty, nameof(json)));

return null;
return new GlobalCache();
}

globalCache = json.ToJsonObject<GlobalCache>();
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);

return null;
return new GlobalCache();
}

if (globalCache == null) {
ASF.ArchiLogger.LogNullError(globalCache);

return null;
return new GlobalCache();
}

return globalCache;
Expand Down

0 comments on commit 69499d5

Please sign in to comment.