Fix profile images.

This commit is contained in:
Patrick Barron
2020-05-20 12:09:52 -04:00
parent 623dcde65c
commit 7d9d54d2ec
5 changed files with 23 additions and 12 deletions

View File

@@ -471,8 +471,17 @@ namespace MediaBrowser.Api.Images
AssertCanUpdateUser(_authContext, _userManager, userId, true);
var user = _userManager.GetUserById(userId);
try
{
File.Delete(user.ProfileImage.Path);
}
catch (IOException e)
{
// TODO: Log this
}
user.ProfileImage = null;
_userManager.UpdateUser(user);
}
/// <summary>
@@ -639,6 +648,7 @@ namespace MediaBrowser.Api.Images
IDictionary<string, string> headers,
bool isHeadRequest)
{
info.Type = ImageType.Profile;
var options = new ImageProcessingOptions
{
CropWhiteSpace = true,
@@ -886,9 +896,10 @@ namespace MediaBrowser.Api.Images
// Handle image/png; charset=utf-8
mimeType = mimeType.Split(';').FirstOrDefault();
var userDataPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username);
user.ProfileImage = new Jellyfin.Data.Entities.ImageInfo(Path.Combine(userDataPath, "profile" + MimeTypes.ToExtension(mimeType)));
await _providerManager
.SaveImage(user, memoryStream, mimeType, Path.Combine(userDataPath, "profile" + MimeTypes.ToExtension(mimeType)))
.SaveImage(user, memoryStream, mimeType, user.ProfileImage.Path)
.ConfigureAwait(false);
await _userManager.UpdateUserAsync(user);
}