diff options
| author | Cody Robibero <cody@robibe.ro> | 2026-08-07 21:40:11 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-07 21:40:11 -0400 |
| commit | 0ec7cc5f5b06bb9361d9f2351626cee2c458593b (patch) | |
| tree | f3ea2d8c021dce5916203bbc64e7cfc2f367aefa /Jellyfin.Server.Implementations | |
| parent | 871970120d20c8715adf8f80cbc50bb012361a9c (diff) | |
| parent | 1c5c95ad1d8e1dde223afcb85c88c65c8fa3b71d (diff) | |
Merge pull request #17555 from IDisposable/fix/reorder-update-items
Delete old related info in bulk as late as possible in UpdateOrInsertItems
Diffstat (limited to 'Jellyfin.Server.Implementations')
| -rw-r--r-- | Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs b/Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs index 57adde44af..3585f85c61 100644 --- a/Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs +++ b/Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs @@ -270,10 +270,6 @@ public class ItemPersistenceService : IItemPersistenceService } else { - context.BaseItemProviders.Where(e => e.ItemId == entity.Id).ExecuteDelete(); - context.BaseItemImageInfos.Where(e => e.ItemId == entity.Id).ExecuteDelete(); - context.BaseItemMetadataFields.Where(e => e.ItemId == entity.Id).ExecuteDelete(); - if (entity.Images is { Count: > 0 }) { context.BaseItemImageInfos.AddRange(entity.Images); @@ -403,6 +399,15 @@ public class ItemPersistenceService : IItemPersistenceService } } + // Owned rows of updated items are rewritten wholesale; cleared in one statement per table. + if (existingItems.Count > 0) + { + var updatedIds = existingItems.ToArray(); + context.BaseItemProviders.WhereOneOrMany(updatedIds, e => e.ItemId).ExecuteDelete(); + context.BaseItemImageInfos.WhereOneOrMany(updatedIds, e => e.ItemId).ExecuteDelete(); + context.BaseItemMetadataFields.WhereOneOrMany(updatedIds, e => e.ItemId).ExecuteDelete(); + } + context.SaveChanges(); var folderIds = tuples |
