Handle empty cache file case
- Issue MatterHackers/MCCentral#5530 Error loading cached OemProfiles data crashes MatterControl
This commit is contained in:
parent
3a1c68cc8e
commit
0dae638ca0
1 changed files with 6 additions and 1 deletions
|
|
@ -177,7 +177,12 @@ namespace MatterHackers.MatterControl.SettingsManagement
|
|||
string cachePath = ApplicationController.CacheablePath("public-profiles", "oemprofiles.json");
|
||||
|
||||
// Load data from cache or fall back to stale StaticData content
|
||||
string json = File.Exists(cachePath) ? File.ReadAllText(cachePath) : AggContext.StaticData.ReadAllText(Path.Combine("Profiles", "oemprofiles.json"));
|
||||
string json = File.Exists(cachePath) ? File.ReadAllText(cachePath) : null;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(json))
|
||||
{
|
||||
json = AggContext.StaticData.ReadAllText(Path.Combine("Profiles", "oemprofiles.json"));
|
||||
}
|
||||
|
||||
return JsonConvert.DeserializeObject<OemProfileDictionary>(json);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue