This commit is contained in:
Antony Corbett
2023-02-28 14:14:35 +00:00
parent 331df1f8ed
commit 54b15f3c76
5 changed files with 16 additions and 23 deletions

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -27,7 +27,7 @@ internal static class VersionDetection
var segments = latestVersionUri.Segments;
if (segments.Any())
{
version = segments[segments.Length - 1];
version = segments[^1];
}
}
}

View File

@@ -6,4 +6,4 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("2.1.0.1")]
[assembly: AssemblyVersion("2.1.0.2")]