Convert some code in UserManager to async

This commit is contained in:
Patrick Barron
2020-10-29 20:30:33 -04:00
parent e37805e82e
commit 72263613d0
4 changed files with 26 additions and 29 deletions

View File

@@ -434,9 +434,7 @@ namespace Jellyfin.Server.Implementations.Users
if (authenticationProvider is IHasNewUserPolicy hasNewUserPolicy && user != null)
{
UpdatePolicy(user.Id, hasNewUserPolicy.GetNewUserPolicy());
await UpdateUserAsync(user).ConfigureAwait(false);
await UpdatePolicyAsync(user.Id, hasNewUserPolicy.GetNewUserPolicy()).ConfigureAwait(false);
}
}
}
@@ -615,9 +613,9 @@ namespace Jellyfin.Server.Implementations.Users
}
/// <inheritdoc/>
public void UpdateConfiguration(Guid userId, UserConfiguration config)
public async Task UpdateConfigurationAsync(Guid userId, UserConfiguration config)
{
using var dbContext = _dbProvider.CreateContext();
await using var dbContext = _dbProvider.CreateContext();
var user = dbContext.Users
.Include(u => u.Permissions)
.Include(u => u.Preferences)
@@ -644,13 +642,13 @@ namespace Jellyfin.Server.Implementations.Users
user.SetPreference(PreferenceKind.LatestItemExcludes, config.LatestItemsExcludes);
dbContext.Update(user);
dbContext.SaveChanges();
await dbContext.SaveChangesAsync().ConfigureAwait(false);
}
/// <inheritdoc/>
public void UpdatePolicy(Guid userId, UserPolicy policy)
public async Task UpdatePolicyAsync(Guid userId, UserPolicy policy)
{
using var dbContext = _dbProvider.CreateContext();
await using var dbContext = _dbProvider.CreateContext();
var user = dbContext.Users
.Include(u => u.Permissions)
.Include(u => u.Preferences)
@@ -715,15 +713,15 @@ namespace Jellyfin.Server.Implementations.Users
user.SetPreference(PreferenceKind.EnableContentDeletionFromFolders, policy.EnableContentDeletionFromFolders);
dbContext.Update(user);
dbContext.SaveChanges();
await dbContext.SaveChangesAsync().ConfigureAwait(false);
}
/// <inheritdoc/>
public void ClearProfileImage(User user)
public async Task ClearProfileImageAsync(User user)
{
using var dbContext = _dbProvider.CreateContext();
await using var dbContext = _dbProvider.CreateContext();
dbContext.Remove(user.ProfileImage);
dbContext.SaveChanges();
await dbContext.SaveChangesAsync().ConfigureAwait(false);
user.ProfileImage = null;
}