From 8ab750feb90117d12d9553d7de24a7972488d7dd Mon Sep 17 00:00:00 2001 From: Aytackydln Date: Wed, 2 Oct 2024 17:47:09 +0200 Subject: [PATCH] fix OnlineSettings.json not created when non-existing or failed to read --- .../Modules/OnlineConfigs/OnlineConfigsRepository.cs | 12 ++++++++++-- .../Project-Aurora/Modules/OnlineConfiguration.cs | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Project-Aurora/Project-Aurora/Modules/OnlineConfigs/OnlineConfigsRepository.cs b/Project-Aurora/Project-Aurora/Modules/OnlineConfigs/OnlineConfigsRepository.cs index e58cd7050..a06cb1cfb 100644 --- a/Project-Aurora/Project-Aurora/Modules/OnlineConfigs/OnlineConfigsRepository.cs +++ b/Project-Aurora/Project-Aurora/Modules/OnlineConfigs/OnlineConfigsRepository.cs @@ -67,8 +67,16 @@ public static async Task GetOnlineSettingsOnline() { await using var stream = GetJsonStream(cachePath); - var deserialize = await JsonSerializer.DeserializeAsync(stream, JsonSerializerOptions); - return deserialize ?? new T(); + try + { + var deserialize = await JsonSerializer.DeserializeAsync(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) diff --git a/Project-Aurora/Project-Aurora/Modules/OnlineConfiguration.cs b/Project-Aurora/Project-Aurora/Modules/OnlineConfiguration.cs index 65f10d62e..33fd58a96 100644 --- a/Project-Aurora/Project-Aurora/Modules/OnlineConfiguration.cs +++ b/Project-Aurora/Project-Aurora/Modules/OnlineConfiguration.cs @@ -98,7 +98,7 @@ private async Task DownloadAndExtract() try { - await ExtractSettings(); + await DownloadAndExtractRepository(); } catch (Exception e) { @@ -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";