diff --git a/SlicerConfiguration/Settings/ProfileManager.cs b/SlicerConfiguration/Settings/ProfileManager.cs index 83e4a0927..7810e9b8e 100644 --- a/SlicerConfiguration/Settings/ProfileManager.cs +++ b/SlicerConfiguration/Settings/ProfileManager.cs @@ -374,19 +374,24 @@ namespace MatterHackers.MatterControl.SlicerConfiguration private async static Task LoadHttpOemProfile(string make, string model) { string deviceToken = OemSettings.Instance.OemProfiles[make][model]; + string cacheKey = deviceToken + ProfileManager.ProfileExtension; + string cachePath = Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "cache", "profiles", cacheKey); + return await ApplicationController.LoadCacheableAsync( - String.Format("{0}{1}", deviceToken, ProfileManager.ProfileExtension), + cacheKey, "profiles", () => { string responseText = null; - if(!File.Exists(Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "cache", "profiles",String.Format("{0}{1}",deviceToken, ProfileManager.ProfileExtension)))) + if(!File.Exists(cachePath)) { + // If the cache file for the current deviceToken does not exist, attempt to download it responseText = RetrievePublicProfileRequest.DownloadPrinterProfile(deviceToken); } + return Task.FromResult(responseText); }, - Path.Combine("Profiles",make,String.Format("{0}{1}",model,ProfileManager.ProfileExtension))); + Path.Combine("Profiles",make, model + ProfileManager.ProfileExtension)); } public void EnsurePrintersImported()