private List <Download> GetSelectedDatasetFilesFromDownloadFileAsDownloadModel() { var downloadFileInfo = new FileInfo(ApplicationService.GetOldDownloadFilePath()); if (downloadFileInfo.Exists) { Log.Information("Old version of config file - download exists"); try { using (var r = new StreamReader(ApplicationService.GetOldDownloadFilePath())) { var json = r.ReadToEnd(); var selecedForDownload = JsonConvert.DeserializeObject <List <Download> >(json); r.Close(); return(selecedForDownload); } } catch (Exception e) { Log.Error(e, "Could not read from old config file, download.json"); return(new List <Download>()); } } return(new List <Download>()); }
/// <summary> /// Move content from old config file to default config file. /// </summary> public void ConvertDownloadToDefaultConfigFileIfExists() { var selecedForDownload = GetSelectedDatasetFilesFromDownloadFileAsDownloadModel(); if (selecedForDownload.Any()) { Log.Information("Convert from download.json to default.json"); selecedForDownload = RemoveDuplicatesIterative(selecedForDownload); selecedForDownload = ConvertToNewVersionOfDownloadFile(selecedForDownload); if (_configFile.IsDefault()) { WriteToConfigFile(selecedForDownload); File.Delete(ApplicationService.GetOldDownloadFilePath()); } } }