aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Item/PeopleRepository.cs
diff options
context:
space:
mode:
authorJPVenson <github@jpb.email>2025-09-16 21:08:04 +0200
committerGitHub <noreply@github.com>2025-09-16 13:08:04 -0600
commita0b3e2b071509f440db10768f6f8984c7ea382d6 (patch)
tree3f0244dc6002796b98f573f4570eb02aa248282b /Jellyfin.Server.Implementations/Item/PeopleRepository.cs
parent2618a5fba23432c89882bf343f481f4248ae7ab3 (diff)
Optimize internal querying of UserData, other fixes (#14795)
Diffstat (limited to 'Jellyfin.Server.Implementations/Item/PeopleRepository.cs')
-rw-r--r--Jellyfin.Server.Implementations/Item/PeopleRepository.cs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs
index be58e2a52..b52de5dd1 100644
--- a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs
+++ b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs
@@ -68,11 +68,12 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I
/// <inheritdoc />
public void UpdatePeople(Guid itemId, IReadOnlyList<PersonInfo> people)
{
- using var context = _dbProvider.CreateDbContext();
-
// TODO: yes for __SOME__ reason there can be duplicates.
people = people.DistinctBy(e => e.Id).ToArray();
var personids = people.Select(f => f.Id);
+
+ using var context = _dbProvider.CreateDbContext();
+ using var transaction = context.Database.BeginTransaction();
var existingPersons = context.Peoples.Where(p => personids.Contains(p.Id)).Select(f => f.Id).ToArray();
context.Peoples.AddRange(people.Where(e => !existingPersons.Contains(e.Id)).Select(Map));
context.SaveChanges();
@@ -104,6 +105,7 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I
context.PeopleBaseItemMap.RemoveRange(maps);
context.SaveChanges();
+ transaction.Commit();
}
private PersonInfo Map(People people)