From 54b15f3c76f7d17e632f345e91a484516a2902a3 Mon Sep 17 00:00:00 2001 From: Antony Corbett Date: Tue, 28 Feb 2023 14:14:35 +0000 Subject: [PATCH] bump ver --- .../BackupFileService.cs | 23 ++++++------------- .../Helpers/BibleNotesFile.cs | 10 ++++---- JWLMerge.ExcelServices/ExcelService.cs | 2 +- JWLMerge/Helpers/VersionDetection.cs | 2 +- SolutionInfo.cs | 2 +- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/JWLMerge.BackupFileServices/BackupFileService.cs b/JWLMerge.BackupFileServices/BackupFileService.cs index 991dd2c..1ba709e 100644 --- a/JWLMerge.BackupFileServices/BackupFileService.cs +++ b/JWLMerge.BackupFileServices/BackupFileService.cs @@ -673,11 +673,8 @@ public sealed class BackupFileService : IBackupFileService { ProgressMessage($"Reading database {databaseName}"); - var databaseEntry = archive.Entries.FirstOrDefault(x => x.Name.Equals(databaseName, StringComparison.OrdinalIgnoreCase)); - if (databaseEntry == null) - { - throw new BackupFileServicesException("Could not find database entry in jwlibrary file"); - } + var databaseEntry = archive.Entries.FirstOrDefault(x => x.Name.Equals(databaseName, StringComparison.OrdinalIgnoreCase)) + ?? throw new BackupFileServicesException("Could not find database entry in jwlibrary file"); Database result; var tmpFile = Path.GetTempFileName(); @@ -706,11 +703,8 @@ public sealed class BackupFileService : IBackupFileService using var archive = new ZipArchive(File.OpenRead(jwlibraryFile), ZipArchiveMode.Read); var manifest = ReadManifest(Path.GetFileName(jwlibraryFile), archive); - var databaseEntry = archive.Entries.FirstOrDefault(x => x.Name.Equals(manifest.UserDataBackup.DatabaseName, StringComparison.OrdinalIgnoreCase)); - if (databaseEntry == null) - { - throw new BackupFileServicesException($"Could not find database entry in ZipArchive: {jwlibraryFile}"); - } + var databaseEntry = archive.Entries.FirstOrDefault(x => x.Name.Equals(manifest.UserDataBackup.DatabaseName, StringComparison.OrdinalIgnoreCase)) + ?? throw new BackupFileServicesException($"Could not find database entry in ZipArchive: {jwlibraryFile}"); var tmpFile = Path.GetTempFileName(); @@ -724,12 +718,9 @@ public sealed class BackupFileService : IBackupFileService { ProgressMessage("Reading manifest"); - var manifestEntry = archive.Entries.FirstOrDefault(x => x.Name.Equals(ManifestEntryName, StringComparison.OrdinalIgnoreCase)); - if (manifestEntry == null) - { - throw new BackupFileServicesException($"Could not find manifest entry in jwlibrary file: {filename}"); - } - + var manifestEntry = archive.Entries.FirstOrDefault(x => x.Name.Equals(ManifestEntryName, StringComparison.OrdinalIgnoreCase)) + ?? throw new BackupFileServicesException($"Could not find manifest entry in jwlibrary file: {filename}"); + using var stream = new StreamReader(manifestEntry.Open()); var fileContents = stream.ReadToEnd(); diff --git a/JWLMerge.BackupFileServices/Helpers/BibleNotesFile.cs b/JWLMerge.BackupFileServices/Helpers/BibleNotesFile.cs index 28f9d4b..b1aaf78 100644 --- a/JWLMerge.BackupFileServices/Helpers/BibleNotesFile.cs +++ b/JWLMerge.BackupFileServices/Helpers/BibleNotesFile.cs @@ -104,8 +104,10 @@ public class BibleNotesFile ++n; - currentSection = new PubNotesFileSection(new PubSymbolAndLanguage(pubSymbol, languageId)); - currentSection.ContentStartLine = n + 1; + currentSection = new PubNotesFileSection(new PubSymbolAndLanguage(pubSymbol, languageId)) + { + ContentStartLine = n + 1 + }; } if (currentSection != null) @@ -116,7 +118,7 @@ public class BibleNotesFile return result.ToArray(); } - private string[] FileContentsFactory(string filePath) + private static string[] FileContentsFactory(string filePath) { if (string.IsNullOrEmpty(filePath)) { @@ -131,7 +133,7 @@ public class BibleNotesFile return File.ReadAllLines(filePath); } - private string[] FileContentsFactory(string[] fileContents) + private static string[] FileContentsFactory(string[] fileContents) { return fileContents; } diff --git a/JWLMerge.ExcelServices/ExcelService.cs b/JWLMerge.ExcelServices/ExcelService.cs index d1f8421..66e08a0 100644 --- a/JWLMerge.ExcelServices/ExcelService.cs +++ b/JWLMerge.ExcelServices/ExcelService.cs @@ -62,7 +62,7 @@ public class ExcelService : IExportToFileService } var noteContent = noteTooLarge - ? note.NoteContent!.Substring(0, Int16.MaxValue) + ? note.NoteContent![..short.MaxValue] : note.NoteContent; SetCellStringValue(worksheet, row, 1, note.PubSymbol); diff --git a/JWLMerge/Helpers/VersionDetection.cs b/JWLMerge/Helpers/VersionDetection.cs index 34cfa0f..cf1ce70 100644 --- a/JWLMerge/Helpers/VersionDetection.cs +++ b/JWLMerge/Helpers/VersionDetection.cs @@ -27,7 +27,7 @@ internal static class VersionDetection var segments = latestVersionUri.Segments; if (segments.Any()) { - version = segments[segments.Length - 1]; + version = segments[^1]; } } } diff --git a/SolutionInfo.cs b/SolutionInfo.cs index e91943b..e6ed51e 100644 --- a/SolutionInfo.cs +++ b/SolutionInfo.cs @@ -6,4 +6,4 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("2.1.0.1")] \ No newline at end of file +[assembly: AssemblyVersion("2.1.0.2")] \ No newline at end of file