diff options
| author | Cody Robibero <cody@robibe.ro> | 2026-07-20 19:58:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-20 19:58:43 -0400 |
| commit | 23fa02eb59519cdc4c2b15b9778ef006b5e85341 (patch) | |
| tree | 81935eb246e9a5873de65cd7db964d4f97fe3e89 /Jellyfin.Server.Implementations/Users | |
| parent | bea016c9625c4e2cfa90d02bbace95c6fbeb4e37 (diff) | |
| parent | 2326ecdedc042f7f1c2ce2a5da409377c09778d7 (diff) | |
Merge pull request #17282 from TowyTowy/fix/13137-clear-profile-image
Fix profile image being impossible to clear when its in-memory key is temporary
Diffstat (limited to 'Jellyfin.Server.Implementations/Users')
| -rw-r--r-- | Jellyfin.Server.Implementations/Users/UserManager.cs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs index bb877b62b0..41648268a9 100644 --- a/Jellyfin.Server.Implementations/Users/UserManager.cs +++ b/Jellyfin.Server.Implementations/Users/UserManager.cs @@ -889,8 +889,20 @@ namespace Jellyfin.Server.Implementations.Users var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false); await using (dbContext.ConfigureAwait(false)) { - dbContext.Remove(user.ProfileImage); - await dbContext.SaveChangesAsync().ConfigureAwait(false); + // Remove the tracked profile image loaded from the database instead of the + // detached instance on the passed in user. That instance can carry a stale, + // never-persisted (temporary) key, which makes EF Core throw when it is marked + // for deletion, leaving the profile image impossible to clear or replace. + var dbUser = await UserQuery(dbContext) + .AsTracking() + .FirstOrDefaultAsync(u => u.Id == user.Id) + .ConfigureAwait(false); + if (dbUser?.ProfileImage is not null) + { + dbContext.Remove(dbUser.ProfileImage); + dbUser.ProfileImage = null; + await dbContext.SaveChangesAsync().ConfigureAwait(false); + } } user.ProfileImage = null; |
