Skip to content

Commit 1fa4b59

Browse files
authored
Fix: Fixed crash that would occur when settings file was invalid (#13853)
1 parent 04dde27 commit 1fa4b59

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Files.App/Utils/Serialization/Implementation/DefaultJsonSettingsDatabase.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@ public DefaultJsonSettingsDatabase(ISettingsSerializer settingsSerializer, IJson
2727
data = "null";
2828
}
2929

30-
return JsonSettingsSerializer.DeserializeFromJson<ConcurrentDictionary<string, object?>?>(data) ?? new();
30+
try
31+
{
32+
return JsonSettingsSerializer.DeserializeFromJson<ConcurrentDictionary<string, object?>?>(data) ?? new();
33+
}
34+
catch (Exception)
35+
{
36+
// Occurs if the settings file has invalid json
37+
// TODO Display prompt to notify user #710
38+
return JsonSettingsSerializer.DeserializeFromJson<ConcurrentDictionary<string, object?>?>("null") ?? new();
39+
}
3140
}
3241

3342
protected bool SaveSettings(IDictionary<string, object?> data)

0 commit comments

Comments
 (0)