aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoCoreDuo <90222533+MarcoCoreDuo@users.noreply.github.com>2026-01-28 12:11:26 -0500
committerBond_009 <bond.009@outlook.com>2026-01-28 12:11:26 -0500
commit6d34f605a3579568b966d44c1a9379b96b76bfe4 (patch)
tree8cac274c2a0b89874da7c2c730f2765b86aed600
parentdad6f650bc6b2dd6cd9acc69ca009f5e624c7d81 (diff)
Backport pull request #16071 from jellyfin/release-10.11.z
Rehydrate cached UserData after reattachment Original-merge: 95d08b264f68a4348d18746543882356465be3b0 Merged-by: crobibero <cody@robibe.ro> Backported-by: Bond_009 <bond.009@outlook.com>
-rw-r--r--Jellyfin.Server.Implementations/Item/BaseItemRepository.cs34
1 files changed, 24 insertions, 10 deletions
diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs
index 43a3cdf78f..338544ab96 100644
--- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs
+++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs
@@ -762,16 +762,30 @@ public sealed class BaseItemRepository
await using (dbContext.ConfigureAwait(false))
{
- var userKeys = item.GetUserDataKeys().ToArray();
- var retentionDate = (DateTime?)null;
- await dbContext.UserData
- .Where(e => e.ItemId == PlaceholderId)
- .Where(e => userKeys.Contains(e.CustomDataKey))
- .ExecuteUpdateAsync(
- e => e
- .SetProperty(f => f.ItemId, item.Id)
- .SetProperty(f => f.RetentionDate, retentionDate),
- cancellationToken).ConfigureAwait(false);
+ var transaction = await dbContext.Database.BeginTransactionAsync(cancellationToken).ConfigureAwait(false);
+ await using (transaction.ConfigureAwait(false))
+ {
+ var userKeys = item.GetUserDataKeys().ToArray();
+ var retentionDate = (DateTime?)null;
+
+ await dbContext.UserData
+ .Where(e => e.ItemId == PlaceholderId)
+ .Where(e => userKeys.Contains(e.CustomDataKey))
+ .ExecuteUpdateAsync(
+ e => e
+ .SetProperty(f => f.ItemId, item.Id)
+ .SetProperty(f => f.RetentionDate, retentionDate),
+ cancellationToken).ConfigureAwait(false);
+
+ // Rehydrate the cached userdata
+ item.UserData = await dbContext.UserData
+ .AsNoTracking()
+ .Where(e => e.ItemId == item.Id)
+ .ToArrayAsync(cancellationToken)
+ .ConfigureAwait(false);
+
+ await transaction.CommitAsync(cancellationToken).ConfigureAwait(false);
+ }
}
}