Loadcacheable properly loads profiles from static data

- Fixed a bug in downloading profiles from web would write "null" to file if it failed to get a proper file
This commit is contained in:
Matt Moening 2016-09-01 12:12:03 -07:00
parent d7666e0924
commit fd76f828ed
2 changed files with 13 additions and 11 deletions

View file

@ -198,17 +198,19 @@ namespace MatterHackers.MatterControl.SettingsManagement
if (!File.Exists(cachePath))
{
var profile = await ApplicationController.DownloadPublicProfileAsync(profileKey);
string profileJson = JsonConvert.SerializeObject(profile);
if (!string.IsNullOrEmpty(profileJson))
if(profile != null)
{
File.WriteAllText(cachePath, profileJson);
}
if (syncReport != null)
{
reportValue.actionLabel = String.Format("Downloading public profiles for {0}...", oem);
reportValue.percComplete = (double)index / OemProfiles.Count;
syncReport.Report(reportValue);
string profileJson = JsonConvert.SerializeObject(profile);
if (!String.IsNullOrEmpty(profileJson))
{
File.WriteAllText(cachePath, profileJson);
}
if (syncReport != null)
{
reportValue.actionLabel = String.Format("Downloading public profiles for {0}...", oem);
reportValue.percComplete = (double)index / OemProfiles.Count;
syncReport.Report(reportValue);
}
}
}