mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-11-04 03:27:05 -05:00 
			
		
		
		
	* Refactored invite user flow to separate error handling on create user flow and email flow. This should help users that have unique situations. * Switch to using files to check LastWriteTime. Debug code in for Robbie to test on rclone * Updated Parser namespace. Changed the LastWriteTime to check all files and folders.
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using API.Entities;
 | 
						|
using API.Entities.Enums;
 | 
						|
using API.Services.Tasks.Scanner;
 | 
						|
 | 
						|
namespace API.Helpers;
 | 
						|
 | 
						|
public static class SeriesHelper
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// Given a parsedSeries checks if any of the names match against said Series and the format matches
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="series"></param>
 | 
						|
    /// <param name="parsedInfoKey"></param>
 | 
						|
    /// <returns></returns>
 | 
						|
    public static bool FindSeries(Series series, ParsedSeries parsedInfoKey)
 | 
						|
    {
 | 
						|
        return (series.NormalizedName.Equals(parsedInfoKey.NormalizedName) ||
 | 
						|
                Services.Tasks.Scanner.Parser.Parser.Normalize(series.LocalizedName).Equals(parsedInfoKey.NormalizedName) ||
 | 
						|
                Services.Tasks.Scanner.Parser.Parser.Normalize(series.OriginalName).Equals(parsedInfoKey.NormalizedName))
 | 
						|
               && (series.Format == parsedInfoKey.Format || series.Format == MangaFormat.Unknown);
 | 
						|
    }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Removes all instances of missingSeries' Series from existingSeries Collection. Existing series is updated by
 | 
						|
    /// reference and the removed element count is returned.
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="existingSeries">Existing Series in DB</param>
 | 
						|
    /// <param name="missingSeries">Series not found on disk or can't be parsed</param>
 | 
						|
    /// <param name="removeCount"></param>
 | 
						|
    /// <returns>the updated existingSeries</returns>
 | 
						|
    public static IEnumerable<Series> RemoveMissingSeries(IList<Series> existingSeries, IEnumerable<Series> missingSeries, out int removeCount)
 | 
						|
    {
 | 
						|
        var existingCount = existingSeries.Count;
 | 
						|
        var missingList = missingSeries.ToList();
 | 
						|
 | 
						|
        existingSeries = existingSeries.Where(
 | 
						|
            s => !missingList.Exists(
 | 
						|
                m => m.NormalizedName.Equals(s.NormalizedName) && m.Format == s.Format)).ToList();
 | 
						|
 | 
						|
        removeCount = existingCount -  existingSeries.Count;
 | 
						|
 | 
						|
        return existingSeries;
 | 
						|
    }
 | 
						|
}
 |