From 50fe25a631967af4107fa7bf40bd335d4839c5b1 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 2 Jul 2024 14:17:21 +0800 Subject: [PATCH] enhance: only load repository settings if file exists --- src/ViewModels/Repository.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 3246b967..86f47656 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -268,11 +268,18 @@ namespace SourceGit.ViewModels public void Open() { var settingsFile = Path.Combine(_gitDir, "sourcegit.settings"); - try + if (File.Exists(settingsFile)) { - _settings = JsonSerializer.Deserialize(File.ReadAllText(settingsFile), JsonCodeGen.Default.RepositorySettings); + try + { + _settings = JsonSerializer.Deserialize(File.ReadAllText(settingsFile), JsonCodeGen.Default.RepositorySettings); + } + catch + { + _settings = new RepositorySettings(); + } } - catch + else { _settings = new RepositorySettings(); }