aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorevan314159 <110177090+evan314159@users.noreply.github.com>2025-09-20 21:23:04 +0800
committerGitHub <noreply@github.com>2025-09-20 07:23:04 -0600
commit424682523961f1a51fdebcde4f64849b75b9c3af (patch)
tree42166a79b5a04c501ffd513404db3a865f201bae
parent68810c690b813b1ea608c7ff2bd9691fc038fe4e (diff)
Attach before updating/deleting to avoid DbUpdateConcurrencyException (#14746)
-rw-r--r--Jellyfin.Server.Implementations/Users/UserManager.cs4
1 files changed, 3 insertions, 1 deletions
diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs
index 3dfb14d71..d0b41a7f6 100644
--- a/Jellyfin.Server.Implementations/Users/UserManager.cs
+++ b/Jellyfin.Server.Implementations/Users/UserManager.cs
@@ -272,6 +272,7 @@ namespace Jellyfin.Server.Implementations.Users
var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false);
await using (dbContext.ConfigureAwait(false))
{
+ dbContext.Users.Attach(user);
dbContext.Users.Remove(user);
await dbContext.SaveChangesAsync().ConfigureAwait(false);
}
@@ -887,7 +888,8 @@ namespace Jellyfin.Server.Implementations.Users
private async Task UpdateUserInternalAsync(JellyfinDbContext dbContext, User user)
{
- dbContext.Users.Update(user);
+ dbContext.Users.Attach(user);
+ dbContext.Entry(user).State = EntityState.Modified;
_users[user.Id] = user;
await dbContext.SaveChangesAsync().ConfigureAwait(false);
}