Fallback to other locations when ComicInfo.xml not at root of archive (#1551)
* Fallback to other locations when ComicInfo.xml not at root of archive * Better ComicInfo test coverage and benchmarks * Add a rar archive to the ComicInfo test cases
This commit is contained in:
parent
aafbce377b
commit
bc1e314326
8 changed files with 85 additions and 17 deletions
|
@ -328,12 +328,11 @@ public class ArchiveService : IArchiveService
|
|||
return false;
|
||||
}
|
||||
|
||||
private static bool ValidComicInfoArchiveEntry(string fullName, string name)
|
||||
private static bool IsComicInfoArchiveEntry(string fullName, string name)
|
||||
{
|
||||
var filenameWithoutExtension = Path.GetFileNameWithoutExtension(name).ToLower();
|
||||
return !Tasks.Scanner.Parser.Parser.HasBlacklistedFolderInPath(fullName)
|
||||
&& (fullName.Equals(ComicInfoFilename) || (string.IsNullOrEmpty(fullName) && name.Equals(ComicInfoFilename)))
|
||||
&& !filenameWithoutExtension.StartsWith(Tasks.Scanner.Parser.Parser.MacOsMetadataFileStartsWith);
|
||||
&& name.Equals(ComicInfoFilename, StringComparison.OrdinalIgnoreCase)
|
||||
&& !name.StartsWith(Tasks.Scanner.Parser.Parser.MacOsMetadataFileStartsWith);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -356,7 +355,8 @@ public class ArchiveService : IArchiveService
|
|||
{
|
||||
using var archive = ZipFile.OpenRead(archivePath);
|
||||
|
||||
var entry = archive.Entries.FirstOrDefault(x => ValidComicInfoArchiveEntry(x.FullName, x.Name));
|
||||
var entry = archive.Entries.FirstOrDefault(x => (x.FullName ?? x.Name) == ComicInfoFilename) ??
|
||||
archive.Entries.FirstOrDefault(x => IsComicInfoArchiveEntry(x.FullName, x.Name));
|
||||
if (entry != null)
|
||||
{
|
||||
using var stream = entry.Open();
|
||||
|
@ -371,8 +371,9 @@ public class ArchiveService : IArchiveService
|
|||
case ArchiveLibrary.SharpCompress:
|
||||
{
|
||||
using var archive = ArchiveFactory.Open(archivePath);
|
||||
var entry = archive.Entries.FirstOrDefault(entry =>
|
||||
ValidComicInfoArchiveEntry(Path.GetDirectoryName(entry.Key), entry.Key));
|
||||
var entry = archive.Entries.FirstOrDefault(entry => entry.Key == ComicInfoFilename) ??
|
||||
archive.Entries.FirstOrDefault(entry =>
|
||||
IsComicInfoArchiveEntry(Path.GetDirectoryName(entry.Key), entry.Key));
|
||||
|
||||
if (entry != null)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue