diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-22 12:34:58 +0100 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-22 12:34:58 +0100 |
| commit | 6ce5f9dfd5d9a27cf70366f35948b2f02e941389 (patch) | |
| tree | 9ed4aab7f33f3002e5f3f832491d729b6051be23 /Jellyfin.Server | |
| parent | 5541653f73c5ac7d6ff0de79b08ba332d346ee62 (diff) | |
Cleanup folder duplicates of series
Diffstat (limited to 'Jellyfin.Server')
| -rw-r--r-- | Jellyfin.Server/Migrations/Routines/FixIncorrectOwnerIdRelationships.cs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Jellyfin.Server/Migrations/Routines/FixIncorrectOwnerIdRelationships.cs b/Jellyfin.Server/Migrations/Routines/FixIncorrectOwnerIdRelationships.cs index a8445d6da8..b9f5964c6a 100644 --- a/Jellyfin.Server/Migrations/Routines/FixIncorrectOwnerIdRelationships.cs +++ b/Jellyfin.Server/Migrations/Routines/FixIncorrectOwnerIdRelationships.cs @@ -101,7 +101,9 @@ public class FixIncorrectOwnerIdRelationships : IAsyncMigrationRoutine { b.Id, b.Type, - HasChildren = context.BaseItems.Any(c => c.OwnerId.HasValue && c.OwnerId.Value.Equals(b.Id) && c.ExtraType != null && c.ExtraType != 0) + b.DateCreated, + HasOwnedExtras = context.BaseItems.Any(c => c.OwnerId.HasValue && c.OwnerId.Value.Equals(b.Id)), + HasDirectChildren = context.BaseItems.Any(c => c.ParentId.HasValue && c.ParentId.Value.Equals(b.Id)) }) .ToListAsync(cancellationToken) .ConfigureAwait(false); @@ -111,10 +113,13 @@ public class FixIncorrectOwnerIdRelationships : IAsyncMigrationRoutine continue; } - // Keep the item that has legitimate children (extras), then prefer Movie type over Video type, then lowest ID - var itemWithChildren = itemsWithPath.FirstOrDefault(i => i.HasChildren); - var movieTypeItem = itemsWithPath.FirstOrDefault(i => i.Type == "MediaBrowser.Controller.Entities.Movies.Movie"); - var itemToKeep = itemWithChildren ?? movieTypeItem ?? itemsWithPath.MinBy(i => i.Id); + // Keep the item that has direct children, then owned extras, then prefer non-Folder types, then newest + var itemToKeep = itemsWithPath + .OrderByDescending(i => i.HasDirectChildren) + .ThenByDescending(i => i.HasOwnedExtras) + .ThenByDescending(i => i.Type != "MediaBrowser.Controller.Entities.Folder") + .ThenByDescending(i => i.DateCreated) + .First(); if (itemToKeep is null) { continue; |
