aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jellyfin.Data/Entities/ImageInfo.cs12
-rw-r--r--Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs2
-rw-r--r--MediaBrowser.Api/Images/ImageService.cs13
-rw-r--r--MediaBrowser.Controller/Drawing/ImageHelper.cs1
-rw-r--r--MediaBrowser.Model/Entities/ImageType.cs7
5 files changed, 23 insertions, 12 deletions
diff --git a/Jellyfin.Data/Entities/ImageInfo.cs b/Jellyfin.Data/Entities/ImageInfo.cs
index 659369545..8bbce95e4 100644
--- a/Jellyfin.Data/Entities/ImageInfo.cs
+++ b/Jellyfin.Data/Entities/ImageInfo.cs
@@ -6,11 +6,9 @@ namespace Jellyfin.Data.Entities
{
public class ImageInfo
{
- public ImageInfo(string path, int width, int height)
+ public ImageInfo(string path)
{
Path = path;
- Width = width;
- Height = height;
LastModified = DateTime.UtcNow;
}
@@ -20,15 +18,11 @@ namespace Jellyfin.Data.Entities
public int Id { get; protected set; }
[Required]
+ [MaxLength(512)]
+ [StringLength(512)]
public string Path { get; set; }
[Required]
- public int Width { get; set; }
-
- [Required]
- public int Height { get; set; }
-
- [Required]
public DateTime LastModified { get; set; }
}
}
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
index 987c85f4c..a1895247f 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
@@ -118,7 +118,7 @@ namespace Jellyfin.Server.Migrations.Routines
{
ItemImageInfo info = mockup.ImageInfos[0];
- user.ProfileImage = new ImageInfo(info.Path, info.Width, info.Height)
+ user.ProfileImage = new ImageInfo(info.Path)
{
LastModified = info.DateModified
};
diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs
index 1392184df..149c4cb9b 100644
--- a/MediaBrowser.Api/Images/ImageService.cs
+++ b/MediaBrowser.Api/Images/ImageService.cs
@@ -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);
}
diff --git a/MediaBrowser.Controller/Drawing/ImageHelper.cs b/MediaBrowser.Controller/Drawing/ImageHelper.cs
index d5a5f547e..c87a248b5 100644
--- a/MediaBrowser.Controller/Drawing/ImageHelper.cs
+++ b/MediaBrowser.Controller/Drawing/ImageHelper.cs
@@ -57,6 +57,7 @@ namespace MediaBrowser.Controller.Drawing
case ImageType.BoxRear:
case ImageType.Disc:
case ImageType.Menu:
+ case ImageType.Profile:
return 1;
case ImageType.Logo:
return 2.58;
diff --git a/MediaBrowser.Model/Entities/ImageType.cs b/MediaBrowser.Model/Entities/ImageType.cs
index d89a4b3ad..6ea9ee419 100644
--- a/MediaBrowser.Model/Entities/ImageType.cs
+++ b/MediaBrowser.Model/Entities/ImageType.cs
@@ -63,6 +63,11 @@ namespace MediaBrowser.Model.Entities
/// <summary>
/// The box rear.
/// </summary>
- BoxRear = 11
+ BoxRear = 11,
+
+ /// <summary>
+ /// The user profile image.
+ /// </summary>
+ Profile = 12
}
}