From be42ffbc036a633314e48d3b48812ec9f409326c Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Sat, 3 Jan 2026 12:43:06 -0600 Subject: [PATCH] add transaction --- .../Data/Repositories/JellyfinTelevisionRepository.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ErsatzTV.Infrastructure/Data/Repositories/JellyfinTelevisionRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/JellyfinTelevisionRepository.cs index d95e70d16..0b18a464f 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/JellyfinTelevisionRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/JellyfinTelevisionRepository.cs @@ -928,6 +928,8 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository version.Name = incomingVersion.Name; version.DateAdded = incomingVersion.DateAdded; + await using var transaction = await dbContext.Database.BeginTransactionAsync(cancellationToken); + // delete old chapters await dbContext.MediaChapters .Where(c => c.MediaVersionId == version.Id) @@ -947,6 +949,8 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository .ExecuteUpdateAsync(mf => mf.SetProperty(f => f.Path, incomingFile.Path), cancellationToken); await dbContext.SaveChangesAsync(cancellationToken); + + await transaction.CommitAsync(cancellationToken); } }