enhance: only load repository settings if file exists

This commit is contained in:
leo 2024-07-02 14:17:21 +08:00
parent 21ec16b4cc
commit 50fe25a631
No known key found for this signature in database

View file

@ -268,11 +268,18 @@ namespace SourceGit.ViewModels
public void Open() public void Open()
{ {
var settingsFile = Path.Combine(_gitDir, "sourcegit.settings"); 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(); _settings = new RepositorySettings();
} }