Skip to content

Commit

Permalink
fix OnlineSettings.json not created when non-existing or failed to read
Browse files Browse the repository at this point in the history
  • Loading branch information
Aytackydln committed Oct 2, 2024
1 parent 7260619 commit 8ab750f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,16 @@ public static async Task<OnlineSettingsMeta> GetOnlineSettingsOnline()
{
await using var stream = GetJsonStream(cachePath);

var deserialize = await JsonSerializer.DeserializeAsync<T>(stream, JsonSerializerOptions);
return deserialize ?? new T();
try
{
var deserialize = await JsonSerializer.DeserializeAsync<T>(stream, JsonSerializerOptions);
return deserialize ?? new T();
}
catch (Exception e)
{
Global.logger.Error($"Error parsing local json: {cachePath}", e);
}
return new T();
}

private static Stream GetJsonStream(string cachePath)
Expand Down
4 changes: 2 additions & 2 deletions Project-Aurora/Project-Aurora/Modules/OnlineConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private async Task DownloadAndExtract()

try
{
await ExtractSettings();
await DownloadAndExtractRepository();
}
catch (Exception e)
{
Expand Down Expand Up @@ -136,7 +136,7 @@ private async Task Refresh()
}
}

private async Task ExtractSettings()
private async Task DownloadAndExtractRepository()
{
const string zipUrl = "https://github.com/Aurora-RGB/Online-Settings/archive/refs/heads/master.zip";

Expand Down

0 comments on commit 8ab750f

Please sign in to comment.