diff options
| author | Marc Brooks <IDisposable@gmail.com> | 2026-08-04 06:14:31 -0500 |
|---|---|---|
| committer | Marc Brooks <IDisposable@gmail.com> | 2026-08-06 01:00:17 -0500 |
| commit | 1c5c95ad1d8e1dde223afcb85c88c65c8fa3b71d (patch) | |
| tree | 798612e50000a9e33cb357ef2e3688ded6acd874 /Jellyfin.Server.Implementations | |
| parent | 812c81916234a496f02be44016c1421cb0ea076f (diff) | |
Move the deletion of old related info to just before the save
This makes the deletion of BaseItemProviders, BaseItemImageInfos, and BaseItemMetadataFields happen in batch as a contiguous block so the lock isn't held across items, just before the bulk SaveChanges.
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 |
