mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Scan Issues (#470)
* Fixed an oversight where unique file extensions for KavitaStats wouldn't ignore case. * Fixed an issue where series were getting removed then re-added due to bad logic when comparing if the series from disk matched the series in DB based on format.
This commit is contained in:
parent
7e36c56416
commit
9c57984bff
@ -20,7 +20,7 @@ namespace API.Data
|
||||
{
|
||||
var fileExtensions = await _dbContext.MangaFile
|
||||
.AsNoTracking()
|
||||
.Select(x => x.FilePath)
|
||||
.Select(x => x.FilePath.ToLower())
|
||||
.Distinct()
|
||||
.ToArrayAsync();
|
||||
|
||||
|
@ -260,13 +260,43 @@ namespace API.Services.Tasks
|
||||
|
||||
public IEnumerable<Series> FindSeriesNotOnDisk(ICollection<Series> existingSeries, Dictionary<ParsedSeries, List<ParserInfo>> parsedSeries)
|
||||
{
|
||||
// It is safe to check only first since Parser ensures that a Series only has one type
|
||||
var format = MangaFormat.Unknown;
|
||||
var firstPs = parsedSeries.Keys.DistinctBy(ps => ps.Format).FirstOrDefault();
|
||||
if (firstPs != null) format = firstPs.Format;
|
||||
|
||||
var foundSeries = parsedSeries.Select(s => s.Key.Name).ToList();
|
||||
return existingSeries.Where(es => !es.NameInList(foundSeries) || es.Format != format);
|
||||
return existingSeries.Where(es => !es.NameInList(foundSeries) && !SeriesHasMatchingParserInfoFormat(es, parsedSeries));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks each parser info to see if there is a name match and if so, checks if the format matches the Series object.
|
||||
/// This accounts for if the Series has an Unknown type and if so, considers it matching.
|
||||
/// </summary>
|
||||
/// <param name="series"></param>
|
||||
/// <param name="parsedSeries"></param>
|
||||
/// <returns></returns>
|
||||
private static bool SeriesHasMatchingParserInfoFormat(Series series,
|
||||
Dictionary<ParsedSeries, List<ParserInfo>> parsedSeries)
|
||||
{
|
||||
var format = MangaFormat.Unknown;
|
||||
foreach (var pSeries in parsedSeries.Keys)
|
||||
{
|
||||
var name = pSeries.Name;
|
||||
var normalizedName = Parser.Parser.Normalize(name);
|
||||
|
||||
if (normalizedName == series.NormalizedName ||
|
||||
normalizedName == Parser.Parser.Normalize(series.Name) ||
|
||||
name == series.Name || name == series.LocalizedName ||
|
||||
name == series.OriginalName ||
|
||||
normalizedName == Parser.Parser.Normalize(series.OriginalName))
|
||||
{
|
||||
format = pSeries.Format;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (series.Format == MangaFormat.Unknown && format != MangaFormat.Unknown)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return format == series.Format;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user