From f4d1a21404faf5f76de978b5effd661c21eecdff Mon Sep 17 00:00:00 2001 From: Yoshi Askharoun Date: Mon, 4 Sep 2023 10:51:50 -0500 Subject: [PATCH] Prevent TOUTOC error when reading status model --- ZuneModCore/ModManager.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ZuneModCore/ModManager.cs b/ZuneModCore/ModManager.cs index fcb288c..7f2e2a1 100644 --- a/ZuneModCore/ModManager.cs +++ b/ZuneModCore/ModManager.cs @@ -75,18 +75,21 @@ namespace ZuneModCore private static StatusModel GetOrCreateStatusModel() { StatusModel? model = null; - if (File.Exists(CoreStatusFile)) + + try { string json = File.ReadAllText(CoreStatusFile); if (!string.IsNullOrWhiteSpace(json)) model = JsonSerializer.Deserialize(json); } - - model ??= new() + catch { - Version = CurrentVersion, - InstalledMods = new() - }; + model = new() + { + Version = CurrentVersion, + InstalledMods = new() + }; + } Guard.IsNotNull(model, nameof(model)); return model;