mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-03 23:36:38 +01:00
This commit integrates remaining performance changes: - Add batch user data fetching in DtoService to reduce N+1 queries - Add GetNextUpEpisodesBatch in TVSeriesManager for efficient batch retrieval - Update Video/Movie/BoxSet to use LibraryManager for alternate versions - Transition LinkedChild to use ItemId instead of Path (obsolete Path/LibraryItemId) - Update providers and controllers for LinkedChildren-based references - Add NextUpEpisodeBatchResult for batched episode queries - Integrate IDescendantQueryProvider in SqliteDatabaseProvider
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
#nullable disable
|
|
|
|
#pragma warning disable CS1591
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using MediaBrowser.Model.IO;
|
|
|
|
namespace MediaBrowser.Controller.Entities
|
|
{
|
|
public class LinkedChildComparer : IEqualityComparer<LinkedChild>
|
|
{
|
|
private readonly IFileSystem _fileSystem;
|
|
|
|
public LinkedChildComparer(IFileSystem fileSystem)
|
|
{
|
|
_fileSystem = fileSystem;
|
|
}
|
|
|
|
public bool Equals(LinkedChild x, LinkedChild y)
|
|
{
|
|
if (x.Type != y.Type)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Compare by ItemId first (preferred)
|
|
if (x.ItemId.HasValue && y.ItemId.HasValue)
|
|
{
|
|
return x.ItemId.Value.Equals(y.ItemId.Value);
|
|
}
|
|
|
|
#pragma warning disable CS0618 // Type or member is obsolete - fallback for shortcut/legacy comparison
|
|
// Fall back to Path comparison for shortcuts and legacy data
|
|
return _fileSystem.AreEqual(x.Path, y.Path);
|
|
#pragma warning restore CS0618
|
|
}
|
|
|
|
public int GetHashCode(LinkedChild obj)
|
|
{
|
|
// Use ItemId for hash if available, otherwise fall back to legacy fields
|
|
if (obj.ItemId.HasValue && !obj.ItemId.Value.Equals(Guid.Empty))
|
|
{
|
|
return HashCode.Combine(obj.ItemId.Value, obj.Type);
|
|
}
|
|
|
|
#pragma warning disable CS0618 // Type or member is obsolete - fallback for shortcut/legacy hashing
|
|
return ((obj.Path ?? string.Empty) + (obj.LibraryItemId ?? string.Empty) + obj.Type).GetHashCode(StringComparison.Ordinal);
|
|
#pragma warning restore CS0618
|
|
}
|
|
}
|
|
}
|