private void FetchCacheInformation() { if (Directory.Exists(_cachePath) == false) { IsAvailable = false; return; } var metaFilePath = Path.Combine(_cachePath, MetaFileName); if (File.Exists(metaFilePath) == false) { IsAvailable = false; return; } try { using (var reader = new StreamReader(metaFilePath)) { _metadata = JsonConvert.DeserializeObject<AgileBoardCacheMetadata>(reader.ReadToEnd()); if (_metadata.ModelVersion != JiraIssue.ModelVersion) { IsAvailable = false; return; } IsAvailable = true; } } catch (Exception e) { _logger.Info(e, "Invalidating cache because it failed to load."); IsAvailable = false; return; } }
private async Task StoreMetafile() { var metadata = new AgileBoardCacheMetadata { DownloadedTime = DateTime.Now, GeneratorVersion = GetType().Assembly.GetName().Version, ModelVersion = JiraIssue.ModelVersion }; var metaFilePath = Path.Combine(_cachePath, MetaFileName); using (var writer = new StreamWriter(metaFilePath)) { await writer.WriteAsync(JsonConvert.SerializeObject(metadata)); } }