Merge pull request #5395 from barronpm/ef-cleanup

pull/5538/head
Bond-009 4 years ago committed by GitHub
commit f2125da9f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -352,8 +352,13 @@ namespace Emby.Drawing
} }
/// <inheritdoc /> /// <inheritdoc />
public string GetImageCacheTag(User user) public string? GetImageCacheTag(User user)
{ {
if (user.ProfileImage == null)
{
return null;
}
return (user.ProfileImage.Path + user.ProfileImage.LastModified.Ticks).GetMD5() return (user.ProfileImage.Path + user.ProfileImage.LastModified.Ticks).GetMD5()
.ToString("N", CultureInfo.InvariantCulture); .ToString("N", CultureInfo.InvariantCulture);
} }

@ -27,6 +27,7 @@
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.3" />
<PackageReference Include="Mono.Nat" Version="3.0.1" /> <PackageReference Include="Mono.Nat" Version="3.0.1" />
<PackageReference Include="prometheus-net.DotNetRuntime" Version="3.4.1" /> <PackageReference Include="prometheus-net.DotNetRuntime" Version="3.4.1" />
<PackageReference Include="sharpcompress" Version="0.28.1" /> <PackageReference Include="sharpcompress" Version="0.28.1" />

@ -196,6 +196,11 @@ namespace Jellyfin.Api.Controllers
} }
var user = _userManager.GetUserById(userId); var user = _userManager.GetUserById(userId);
if (user?.ProfileImage == null)
{
return NoContent();
}
try try
{ {
System.IO.File.Delete(user.ProfileImage.Path); System.IO.File.Delete(user.ProfileImage.Path);
@ -235,6 +240,11 @@ namespace Jellyfin.Api.Controllers
} }
var user = _userManager.GetUserById(userId); var user = _userManager.GetUserById(userId);
if (user?.ProfileImage == null)
{
return NoContent();
}
try try
{ {
System.IO.File.Delete(user.ProfileImage.Path); System.IO.File.Delete(user.ProfileImage.Path);
@ -1469,7 +1479,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex) [FromQuery] int? imageIndex)
{ {
var user = _userManager.GetUserById(userId); var user = _userManager.GetUserById(userId);
if (user == null) if (user?.ProfileImage == null)
{ {
return NotFound(); return NotFound();
} }

@ -132,7 +132,10 @@ namespace Jellyfin.Api.Controllers
{ {
var user = _userManager.Users.First(); var user = _userManager.Users.First();
if (startupUserDto.Name != null)
{
user.Username = startupUserDto.Name; user.Username = startupUserDto.Name;
}
await _userManager.UpdateUserAsync(user).ConfigureAwait(false); await _userManager.UpdateUserAsync(user).ConfigureAwait(false);

@ -1,7 +1,5 @@
using System; using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using System.Xml.Serialization; using System.Xml.Serialization;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
@ -27,14 +25,6 @@ namespace Jellyfin.Data.Entities
EndHour = endHour; EndHour = endHour;
} }
/// <summary>
/// Initializes a new instance of the <see cref="AccessSchedule"/> class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected AccessSchedule()
{
}
/// <summary> /// <summary>
/// Gets or sets the id of this instance. /// Gets or sets the id of this instance.
/// </summary> /// </summary>
@ -42,8 +32,6 @@ namespace Jellyfin.Data.Entities
/// Identity, Indexed, Required. /// Identity, Indexed, Required.
/// </remarks> /// </remarks>
[XmlIgnore] [XmlIgnore]
[Key]
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; } public int Id { get; protected set; }
@ -51,41 +39,24 @@ namespace Jellyfin.Data.Entities
/// Gets or sets the id of the associated user. /// Gets or sets the id of the associated user.
/// </summary> /// </summary>
[XmlIgnore] [XmlIgnore]
[Required]
public Guid UserId { get; protected set; } public Guid UserId { get; protected set; }
/// <summary> /// <summary>
/// Gets or sets the day of week. /// Gets or sets the day of week.
/// </summary> /// </summary>
/// <value>The day of week.</value> /// <value>The day of week.</value>
[Required]
public DynamicDayOfWeek DayOfWeek { get; set; } public DynamicDayOfWeek DayOfWeek { get; set; }
/// <summary> /// <summary>
/// Gets or sets the start hour. /// Gets or sets the start hour.
/// </summary> /// </summary>
/// <value>The start hour.</value> /// <value>The start hour.</value>
[Required]
public double StartHour { get; set; } public double StartHour { get; set; }
/// <summary> /// <summary>
/// Gets or sets the end hour. /// Gets or sets the end hour.
/// </summary> /// </summary>
/// <value>The end hour.</value> /// <value>The end hour.</value>
[Required]
public double EndHour { get; set; } public double EndHour { get; set; }
/// <summary>
/// Static create function (for use in LINQ queries, etc.)
/// </summary>
/// <param name="dayOfWeek">The day of the week.</param>
/// <param name="startHour">The start hour.</param>
/// <param name="endHour">The end hour.</param>
/// <param name="userId">The associated user's id.</param>
/// <returns>The newly created instance.</returns>
public static AccessSchedule Create(DynamicDayOfWeek dayOfWeek, double startHour, double endHour, Guid userId)
{
return new AccessSchedule(dayOfWeek, startHour, endHour, userId);
}
} }
} }

@ -18,8 +18,7 @@ namespace Jellyfin.Data.Entities
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
/// <param name="type">The type.</param> /// <param name="type">The type.</param>
/// <param name="userId">The user id.</param> /// <param name="userId">The user id.</param>
/// <param name="logLevel">The log level.</param> public ActivityLog(string name, string type, Guid userId)
public ActivityLog(string name, string type, Guid userId, LogLevel logLevel = LogLevel.Information)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -35,15 +34,7 @@ namespace Jellyfin.Data.Entities
Type = type; Type = type;
UserId = userId; UserId = userId;
DateCreated = DateTime.UtcNow; DateCreated = DateTime.UtcNow;
LogSeverity = logLevel; LogSeverity = LogLevel.Information;
}
/// <summary>
/// Initializes a new instance of the <see cref="ActivityLog"/> class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected ActivityLog()
{
} }
/// <summary> /// <summary>
@ -59,7 +50,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 512. /// Required, Max length = 512.
/// </remarks> /// </remarks>
[Required]
[MaxLength(512)] [MaxLength(512)]
[StringLength(512)] [StringLength(512)]
public string Name { get; set; } public string Name { get; set; }
@ -72,7 +62,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(512)] [MaxLength(512)]
[StringLength(512)] [StringLength(512)]
public string Overview { get; set; } public string? Overview { get; set; }
/// <summary> /// <summary>
/// Gets or sets the short overview. /// Gets or sets the short overview.
@ -82,7 +72,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(512)] [MaxLength(512)]
[StringLength(512)] [StringLength(512)]
public string ShortOverview { get; set; } public string? ShortOverview { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type. /// Gets or sets the type.
@ -90,7 +80,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 256. /// Required, Max length = 256.
/// </remarks> /// </remarks>
[Required]
[MaxLength(256)] [MaxLength(256)]
[StringLength(256)] [StringLength(256)]
public string Type { get; set; } public string Type { get; set; }
@ -111,7 +100,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(256)] [MaxLength(256)]
[StringLength(256)] [StringLength(256)]
public string ItemId { get; set; } public string? ItemId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the date created. This should be in UTC. /// Gets or sets the date created. This should be in UTC.

@ -15,22 +15,15 @@ namespace Jellyfin.Data.Entities
/// <param name="userId">The user id.</param> /// <param name="userId">The user id.</param>
/// <param name="itemId">The item id.</param> /// <param name="itemId">The item id.</param>
/// <param name="client">The client.</param> /// <param name="client">The client.</param>
/// <param name="preferenceKey">The preference key.</param> /// <param name="key">The preference key.</param>
/// <param name="preferenceValue">The preference value.</param> /// <param name="value">The preference value.</param>
public CustomItemDisplayPreferences(Guid userId, Guid itemId, string client, string preferenceKey, string preferenceValue) public CustomItemDisplayPreferences(Guid userId, Guid itemId, string client, string key, string value)
{ {
UserId = userId; UserId = userId;
ItemId = itemId; ItemId = itemId;
Client = client; Client = client;
Key = preferenceKey; Key = key;
Value = preferenceValue; Value = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="CustomItemDisplayPreferences"/> class.
/// </summary>
protected CustomItemDisplayPreferences()
{
} }
/// <summary> /// <summary>
@ -64,7 +57,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. Max Length = 32. /// Required. Max Length = 32.
/// </remarks> /// </remarks>
[Required]
[MaxLength(32)] [MaxLength(32)]
[StringLength(32)] [StringLength(32)]
public string Client { get; set; } public string Client { get; set; }
@ -75,7 +67,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
public string Key { get; set; } public string Key { get; set; }
/// <summary> /// <summary>
@ -84,7 +75,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
public string Value { get; set; } public string Value { get; set; }
} }
} }

@ -30,19 +30,10 @@ namespace Jellyfin.Data.Entities
SkipBackwardLength = 10000; SkipBackwardLength = 10000;
ScrollDirection = ScrollDirection.Horizontal; ScrollDirection = ScrollDirection.Horizontal;
ChromecastVersion = ChromecastVersion.Stable; ChromecastVersion = ChromecastVersion.Stable;
DashboardTheme = string.Empty;
TvHome = string.Empty;
HomeSections = new HashSet<HomeSection>(); HomeSections = new HashSet<HomeSection>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="DisplayPreferences"/> class.
/// </summary>
protected DisplayPreferences()
{
}
/// <summary> /// <summary>
/// Gets or sets the Id. /// Gets or sets the Id.
/// </summary> /// </summary>
@ -74,7 +65,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. Max Length = 32. /// Required. Max Length = 32.
/// </remarks> /// </remarks>
[Required]
[MaxLength(32)] [MaxLength(32)]
[StringLength(32)] [StringLength(32)]
public string Client { get; set; } public string Client { get; set; }
@ -145,14 +135,14 @@ namespace Jellyfin.Data.Entities
/// </summary> /// </summary>
[MaxLength(32)] [MaxLength(32)]
[StringLength(32)] [StringLength(32)]
public string DashboardTheme { get; set; } public string? DashboardTheme { get; set; }
/// <summary> /// <summary>
/// Gets or sets the tv home screen. /// Gets or sets the tv home screen.
/// </summary> /// </summary>
[MaxLength(32)] [MaxLength(32)]
[StringLength(32)] [StringLength(32)]
public string TvHome { get; set; } public string? TvHome { get; set; }
/// <summary> /// <summary>
/// Gets or sets the home sections. /// Gets or sets the home sections.

@ -32,16 +32,6 @@ namespace Jellyfin.Data.Entities
Preferences = new HashSet<Preference>(); Preferences = new HashSet<Preference>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Group"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Group()
{
}
/// <summary> /// <summary>
/// Gets or sets the id of this group. /// Gets or sets the id of this group.
/// </summary> /// </summary>
@ -56,7 +46,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 255. /// Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string Name { get; set; } public string Name { get; set; }

@ -15,7 +15,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Identity. Required. /// Identity. Required.
/// </remarks> /// </remarks>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; } public int Id { get; protected set; }

@ -19,16 +19,6 @@ namespace Jellyfin.Data.Entities
LastModified = DateTime.UtcNow; LastModified = DateTime.UtcNow;
} }
/// <summary>
/// Initializes a new instance of the <see cref="ImageInfo"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected ImageInfo()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
@ -49,7 +39,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
[MaxLength(512)] [MaxLength(512)]
[StringLength(512)] [StringLength(512)]
public string Path { get; set; } public string Path { get; set; }

@ -28,13 +28,6 @@ namespace Jellyfin.Data.Entities
RememberIndexing = false; RememberIndexing = false;
} }
/// <summary>
/// Initializes a new instance of the <see cref="ItemDisplayPreferences"/> class.
/// </summary>
protected ItemDisplayPreferences()
{
}
/// <summary> /// <summary>
/// Gets or sets the Id. /// Gets or sets the Id.
/// </summary> /// </summary>
@ -66,7 +59,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. Max Length = 32. /// Required. Max Length = 32.
/// </remarks> /// </remarks>
[Required]
[MaxLength(32)] [MaxLength(32)]
[StringLength(32)] [StringLength(32)]
public string Client { get; set; } public string Client { get; set; }
@ -106,7 +98,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
[MaxLength(64)] [MaxLength(64)]
[StringLength(64)] [StringLength(64)]
public string SortBy { get; set; } public string SortBy { get; set; }

@ -18,8 +18,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="kind">The kind of art.</param> /// <param name="kind">The kind of art.</param>
/// <param name="owner">The owner.</param> public Artwork(string path, ArtKind kind)
public Artwork(string path, ArtKind kind, IHasArtwork owner)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
@ -28,18 +27,6 @@ namespace Jellyfin.Data.Entities.Libraries
Path = path; Path = path;
Kind = kind; Kind = kind;
owner?.Artwork.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="Artwork"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Artwork()
{
} }
/// <summary> /// <summary>
@ -57,7 +44,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 65535. /// Required, Max length = 65535.
/// </remarks> /// </remarks>
[Required]
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Path { get; set; } public string Path { get; set; }

@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Book"/> class. /// Initializes a new instance of the <see cref="Book"/> class.
/// </summary> /// </summary>
public Book() /// <param name="library">The library.</param>
public Book(Library library) : base(library)
{ {
BookMetadata = new HashSet<BookMetadata>(); BookMetadata = new HashSet<BookMetadata>();
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();

@ -1,8 +1,6 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -17,29 +15,11 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="book">The book.</param> public BookMetadata(string title, string language) : base(title, language)
public BookMetadata(string title, string language, Book book) : base(title, language)
{ {
if (book == null)
{
throw new ArgumentNullException(nameof(book));
}
book.BookMetadata.Add(this);
Publishers = new HashSet<Company>(); Publishers = new HashSet<Company>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="BookMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected BookMetadata()
{
}
/// <summary> /// <summary>
/// Gets or sets the ISBN. /// Gets or sets the ISBN.
/// </summary> /// </summary>
@ -51,7 +31,6 @@ namespace Jellyfin.Data.Entities.Libraries
public virtual ICollection<Company> Publishers { get; protected set; } public virtual ICollection<Company> Publishers { get; protected set; }
/// <inheritdoc /> /// <inheritdoc />
[NotMapped]
public ICollection<Company> Companies => Publishers; public ICollection<Company> Companies => Publishers;
} }
} }

@ -17,8 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="startTime">The start time for this chapter.</param> /// <param name="startTime">The start time for this chapter.</param>
/// <param name="release">The release.</param> public Chapter(string language, long startTime)
public Chapter(string language, long startTime, Release release)
{ {
if (string.IsNullOrEmpty(language)) if (string.IsNullOrEmpty(language))
{ {
@ -27,23 +26,6 @@ namespace Jellyfin.Data.Entities.Libraries
Language = language; Language = language;
StartTime = startTime; StartTime = startTime;
if (release == null)
{
throw new ArgumentNullException(nameof(release));
}
release.Chapters.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="Chapter"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Chapter()
{
} }
/// <summary> /// <summary>
@ -63,7 +45,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string? Name { get; set; }
/// <summary> /// <summary>
/// Gets or sets the language. /// Gets or sets the language.
@ -72,7 +54,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// Required, Min length = 3, Max length = 3 /// Required, Min length = 3, Max length = 3
/// ISO-639-3 3-character language codes. /// ISO-639-3 3-character language codes.
/// </remarks> /// </remarks>
[Required]
[MinLength(3)] [MinLength(3)]
[MaxLength(3)] [MaxLength(3)]
[StringLength(3)] [StringLength(3)]

@ -38,7 +38,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string? Name { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[ConcurrencyCheck] [ConcurrencyCheck]

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -13,39 +12,10 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="CollectionItem"/> class. /// Initializes a new instance of the <see cref="CollectionItem"/> class.
/// </summary> /// </summary>
/// <param name="collection">The collection.</param> /// <param name="libraryItem">The library item.</param>
/// <param name="previous">The previous item.</param> public CollectionItem(LibraryItem libraryItem)
/// <param name="next">The next item.</param>
public CollectionItem(Collection collection, CollectionItem previous, CollectionItem next)
{
if (collection == null)
{
throw new ArgumentNullException(nameof(collection));
}
collection.Items.Add(this);
if (next != null)
{
Next = next;
next.Previous = this;
}
if (previous != null)
{
Previous = previous;
previous.Next = this;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="CollectionItem"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected CollectionItem()
{ {
LibraryItem = libraryItem;
} }
/// <summary> /// <summary>
@ -75,7 +45,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// TODO check if this properly updated Dependant and has the proper principal relationship. /// TODO check if this properly updated Dependant and has the proper principal relationship.
/// </remarks> /// </remarks>
public virtual CollectionItem Next { get; set; } public virtual CollectionItem? Next { get; set; }
/// <summary> /// <summary>
/// Gets or sets the previous item in the collection. /// Gets or sets the previous item in the collection.
@ -83,7 +53,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// TODO check if this properly updated Dependant and has the proper principal relationship. /// TODO check if this properly updated Dependant and has the proper principal relationship.
/// </remarks> /// </remarks>
public virtual CollectionItem Previous { get; set; } public virtual CollectionItem? Previous { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public void OnSavingChanges() public void OnSavingChanges()

@ -15,22 +15,10 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Company"/> class. /// Initializes a new instance of the <see cref="Company"/> class.
/// </summary> /// </summary>
/// <param name="owner">The owner of this company.</param> public Company()
public Company(IHasCompanies owner)
{ {
owner?.Companies.Add(this);
CompanyMetadata = new HashSet<CompanyMetadata>(); CompanyMetadata = new HashSet<CompanyMetadata>();
} ChildCompanies = new HashSet<Company>();
/// <summary>
/// Initializes a new instance of the <see cref="Company"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Company()
{
} }
/// <summary> /// <summary>
@ -57,7 +45,6 @@ namespace Jellyfin.Data.Entities.Libraries
public virtual ICollection<Company> ChildCompanies { get; protected set; } public virtual ICollection<Company> ChildCompanies { get; protected set; }
/// <inheritdoc /> /// <inheritdoc />
[NotMapped]
public ICollection<Company> Companies => ChildCompanies; public ICollection<Company> Companies => ChildCompanies;
/// <inheritdoc /> /// <inheritdoc />

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -13,21 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="company">The company.</param> public CompanyMetadata(string title, string language) : base(title, language)
public CompanyMetadata(string title, string language, Company company) : base(title, language)
{
if (company == null)
{
throw new ArgumentNullException(nameof(company));
}
company.CompanyMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="CompanyMetadata"/> class.
/// </summary>
protected CompanyMetadata()
{ {
} }
@ -39,7 +24,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Description { get; set; } public string? Description { get; set; }
/// <summary> /// <summary>
/// Gets or sets the headquarters. /// Gets or sets the headquarters.
@ -49,7 +34,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string Headquarters { get; set; } public string? Headquarters { get; set; }
/// <summary> /// <summary>
/// Gets or sets the country code. /// Gets or sets the country code.
@ -59,7 +44,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(2)] [MaxLength(2)]
[StringLength(2)] [StringLength(2)]
public string Country { get; set; } public string? Country { get; set; }
/// <summary> /// <summary>
/// Gets or sets the homepage. /// Gets or sets the homepage.
@ -69,6 +54,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Homepage { get; set; } public string? Homepage { get; set; }
} }
} }

@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="CustomItem"/> class. /// Initializes a new instance of the <see cref="CustomItem"/> class.
/// </summary> /// </summary>
public CustomItem() /// <param name="library">The library.</param>
public CustomItem(Library library) : base(library)
{ {
CustomItemMetadata = new HashSet<CustomItemMetadata>(); CustomItemMetadata = new HashSet<CustomItemMetadata>();
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();

@ -1,5 +1,3 @@
using System;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
{ {
/// <summary> /// <summary>
@ -12,24 +10,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="item">The item.</param> public CustomItemMetadata(string title, string language) : base(title, language)
public CustomItemMetadata(string title, string language, CustomItem item) : base(title, language)
{
if (item == null)
{
throw new ArgumentNullException(nameof(item));
}
item.CustomItemMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="CustomItemMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected CustomItemMetadata()
{ {
} }
} }

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,30 +13,13 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Episode"/> class. /// Initializes a new instance of the <see cref="Episode"/> class.
/// </summary> /// </summary>
/// <param name="season">The season.</param> /// <param name="library">The library.</param>
public Episode(Season season) public Episode(Library library) : base(library)
{ {
if (season == null)
{
throw new ArgumentNullException(nameof(season));
}
season.Episodes.Add(this);
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();
EpisodeMetadata = new HashSet<EpisodeMetadata>(); EpisodeMetadata = new HashSet<EpisodeMetadata>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Episode"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Episode()
{
}
/// <summary> /// <summary>
/// Gets or sets the episode number. /// Gets or sets the episode number.
/// </summary> /// </summary>

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -13,24 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="episode">The episode.</param> public EpisodeMetadata(string title, string language) : base(title, language)
public EpisodeMetadata(string title, string language, Episode episode) : base(title, language)
{
if (episode == null)
{
throw new ArgumentNullException(nameof(episode));
}
episode.EpisodeMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="EpisodeMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected EpisodeMetadata()
{ {
} }
@ -42,7 +24,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Outline { get; set; } public string? Outline { get; set; }
/// <summary> /// <summary>
/// Gets or sets the plot. /// Gets or sets the plot.
@ -52,7 +34,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Plot { get; set; } public string? Plot { get; set; }
/// <summary> /// <summary>
/// Gets or sets the tagline. /// Gets or sets the tagline.
@ -62,6 +44,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Tagline { get; set; } public string? Tagline { get; set; }
} }
} }

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,32 +13,9 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="Genre"/> class. /// Initializes a new instance of the <see cref="Genre"/> class.
/// </summary> /// </summary>
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
/// <param name="itemMetadata">The metadata.</param> public Genre(string name)
public Genre(string name, ItemMetadata itemMetadata)
{ {
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}
Name = name; Name = name;
if (itemMetadata == null)
{
throw new ArgumentNullException(nameof(itemMetadata));
}
itemMetadata.Genres.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="Genre"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Genre()
{
} }
/// <summary> /// <summary>
@ -57,7 +33,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Indexed, Required, Max length = 255. /// Indexed, Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string Name { get; set; } public string Name { get; set; }

@ -42,16 +42,6 @@ namespace Jellyfin.Data.Entities.Libraries
Sources = new HashSet<MetadataProviderId>(); Sources = new HashSet<MetadataProviderId>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="ItemMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to being abstract.
/// </remarks>
protected ItemMetadata()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
@ -67,7 +57,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 1024. /// Required, Max length = 1024.
/// </remarks> /// </remarks>
[Required]
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Title { get; set; } public string Title { get; set; }
@ -80,7 +69,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string OriginalTitle { get; set; } public string? OriginalTitle { get; set; }
/// <summary> /// <summary>
/// Gets or sets the sort title. /// Gets or sets the sort title.
@ -90,7 +79,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string SortTitle { get; set; } public string? SortTitle { get; set; }
/// <summary> /// <summary>
/// Gets or sets the language. /// Gets or sets the language.
@ -99,7 +88,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// Required, Min length = 3, Max length = 3. /// Required, Min length = 3, Max length = 3.
/// ISO-639-3 3-character language codes. /// ISO-639-3 3-character language codes.
/// </remarks> /// </remarks>
[Required]
[MinLength(3)] [MinLength(3)]
[MaxLength(3)] [MaxLength(3)]
[StringLength(3)] [StringLength(3)]

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,24 +13,11 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="Library"/> class. /// Initializes a new instance of the <see cref="Library"/> class.
/// </summary> /// </summary>
/// <param name="name">The name of the library.</param> /// <param name="name">The name of the library.</param>
public Library(string name) /// <param name="path">The path of the library.</param>
public Library(string name, string path)
{ {
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException(nameof(name));
}
Name = name; Name = name;
} Path = path;
/// <summary>
/// Initializes a new instance of the <see cref="Library"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Library()
{
} }
/// <summary> /// <summary>
@ -49,7 +35,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 128. /// Required, Max length = 128.
/// </remarks> /// </remarks>
[Required]
[MaxLength(128)] [MaxLength(128)]
[StringLength(128)] [StringLength(128)]
public string Name { get; set; } public string Name { get; set; }
@ -60,7 +45,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
public string Path { get; set; } public string Path { get; set; }
/// <inheritdoc /> /// <inheritdoc />

@ -20,13 +20,6 @@ namespace Jellyfin.Data.Entities.Libraries
Library = library; Library = library;
} }
/// <summary>
/// Initializes a new instance of the <see cref="LibraryItem"/> class.
/// </summary>
protected LibraryItem()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
@ -51,7 +44,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
public virtual Library Library { get; set; } public virtual Library Library { get; set; }
/// <inheritdoc /> /// <inheritdoc />

@ -19,8 +19,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="path">The path relative to the LibraryRoot.</param> /// <param name="path">The path relative to the LibraryRoot.</param>
/// <param name="kind">The file kind.</param> /// <param name="kind">The file kind.</param>
/// <param name="release">The release.</param> public MediaFile(string path, MediaFileKind kind)
public MediaFile(string path, MediaFileKind kind, Release release)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
@ -30,26 +29,9 @@ namespace Jellyfin.Data.Entities.Libraries
Path = path; Path = path;
Kind = kind; Kind = kind;
if (release == null)
{
throw new ArgumentNullException(nameof(release));
}
release.MediaFiles.Add(this);
MediaFileStreams = new HashSet<MediaFileStream>(); MediaFileStreams = new HashSet<MediaFileStream>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="MediaFile"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MediaFile()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
@ -65,7 +47,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 65535. /// Required, Max length = 65535.
/// </remarks> /// </remarks>
[Required]
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Path { get; set; } public string Path { get; set; }

@ -1,6 +1,5 @@
#pragma warning disable CA1711 // Identifiers should not have incorrect suffix #pragma warning disable CA1711 // Identifiers should not have incorrect suffix
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -16,27 +15,9 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="MediaFileStream"/> class. /// Initializes a new instance of the <see cref="MediaFileStream"/> class.
/// </summary> /// </summary>
/// <param name="streamNumber">The number of this stream.</param> /// <param name="streamNumber">The number of this stream.</param>
/// <param name="mediaFile">The media file.</param> public MediaFileStream(int streamNumber)
public MediaFileStream(int streamNumber, MediaFile mediaFile)
{ {
StreamNumber = streamNumber; StreamNumber = streamNumber;
if (mediaFile == null)
{
throw new ArgumentNullException(nameof(mediaFile));
}
mediaFile.MediaFileStreams.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="MediaFileStream"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MediaFileStream()
{
} }
/// <summary> /// <summary>

@ -24,16 +24,6 @@ namespace Jellyfin.Data.Entities.Libraries
Name = name; Name = name;
} }
/// <summary>
/// Initializes a new instance of the <see cref="MetadataProvider"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MetadataProvider()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
@ -49,7 +39,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 1024. /// Required, Max length = 1024.
/// </remarks> /// </remarks>
[Required]
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string Name { get; set; }

@ -14,8 +14,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="MetadataProviderId"/> class. /// Initializes a new instance of the <see cref="MetadataProviderId"/> class.
/// </summary> /// </summary>
/// <param name="providerId">The provider id.</param> /// <param name="providerId">The provider id.</param>
/// <param name="itemMetadata">The metadata entity.</param> /// <param name="metadataProvider">The metadata provider.</param>
public MetadataProviderId(string providerId, ItemMetadata itemMetadata) public MetadataProviderId(string providerId, MetadataProvider metadataProvider)
{ {
if (string.IsNullOrEmpty(providerId)) if (string.IsNullOrEmpty(providerId))
{ {
@ -23,23 +23,7 @@ namespace Jellyfin.Data.Entities.Libraries
} }
ProviderId = providerId; ProviderId = providerId;
MetadataProvider = metadataProvider;
if (itemMetadata == null)
{
throw new ArgumentNullException(nameof(itemMetadata));
}
itemMetadata.Sources.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="MetadataProviderId"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MetadataProviderId()
{
} }
/// <summary> /// <summary>
@ -57,7 +41,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 255. /// Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string ProviderId { get; set; } public string ProviderId { get; set; }

@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Movie"/> class. /// Initializes a new instance of the <see cref="Movie"/> class.
/// </summary> /// </summary>
public Movie() /// <param name="library">The library.</param>
public Movie(Library library) : base(library)
{ {
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();
MovieMetadata = new HashSet<MovieMetadata>(); MovieMetadata = new HashSet<MovieMetadata>();

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -17,22 +16,9 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the movie.</param> /// <param name="title">The title or name of the movie.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="movie">The movie.</param> public MovieMetadata(string title, string language) : base(title, language)
public MovieMetadata(string title, string language, Movie movie) : base(title, language)
{ {
Studios = new HashSet<Company>(); Studios = new HashSet<Company>();
movie.MovieMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="MovieMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MovieMetadata()
{
} }
/// <summary> /// <summary>
@ -43,7 +29,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Outline { get; set; } public string? Outline { get; set; }
/// <summary> /// <summary>
/// Gets or sets the tagline. /// Gets or sets the tagline.
@ -53,7 +39,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Tagline { get; set; } public string? Tagline { get; set; }
/// <summary> /// <summary>
/// Gets or sets the plot. /// Gets or sets the plot.
@ -63,7 +49,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Plot { get; set; } public string? Plot { get; set; }
/// <summary> /// <summary>
/// Gets or sets the country code. /// Gets or sets the country code.
@ -73,7 +59,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(2)] [MaxLength(2)]
[StringLength(2)] [StringLength(2)]
public string Country { get; set; } public string? Country { get; set; }
/// <summary> /// <summary>
/// Gets or sets the studios that produced this movie. /// Gets or sets the studios that produced this movie.
@ -81,7 +67,6 @@ namespace Jellyfin.Data.Entities.Libraries
public virtual ICollection<Company> Studios { get; protected set; } public virtual ICollection<Company> Studios { get; protected set; }
/// <inheritdoc /> /// <inheritdoc />
[NotMapped]
public ICollection<Company> Companies => Studios; public ICollection<Company> Companies => Studios;
} }
} }

@ -12,7 +12,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MusicAlbum"/> class. /// Initializes a new instance of the <see cref="MusicAlbum"/> class.
/// </summary> /// </summary>
public MusicAlbum() /// <param name="library">The library.</param>
public MusicAlbum(Library library) : base(library)
{ {
MusicAlbumMetadata = new HashSet<MusicAlbumMetadata>(); MusicAlbumMetadata = new HashSet<MusicAlbumMetadata>();
Tracks = new HashSet<Track>(); Tracks = new HashSet<Track>();

@ -15,22 +15,9 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the album.</param> /// <param name="title">The title or name of the album.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="album">The music album.</param> public MusicAlbumMetadata(string title, string language) : base(title, language)
public MusicAlbumMetadata(string title, string language, MusicAlbum album) : base(title, language)
{ {
Labels = new HashSet<Company>(); Labels = new HashSet<Company>();
album.MusicAlbumMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="MusicAlbumMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MusicAlbumMetadata()
{
} }
/// <summary> /// <summary>
@ -41,7 +28,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string Barcode { get; set; } public string? Barcode { get; set; }
/// <summary> /// <summary>
/// Gets or sets the label number. /// Gets or sets the label number.
@ -51,7 +38,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string LabelNumber { get; set; } public string? LabelNumber { get; set; }
/// <summary> /// <summary>
/// Gets or sets the country code. /// Gets or sets the country code.
@ -61,7 +48,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(2)] [MaxLength(2)]
[StringLength(2)] [StringLength(2)]
public string Country { get; set; } public string? Country { get; set; }
/// <summary> /// <summary>
/// Gets or sets a collection containing the labels. /// Gets or sets a collection containing the labels.

@ -31,16 +31,6 @@ namespace Jellyfin.Data.Entities.Libraries
Sources = new HashSet<MetadataProviderId>(); Sources = new HashSet<MetadataProviderId>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Person"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Person()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
@ -56,7 +46,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 1024. /// Required, Max length = 1024.
/// </remarks> /// </remarks>
[Required]
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string Name { get; set; }
@ -69,7 +58,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(256)] [MaxLength(256)]
[StringLength(256)] [StringLength(256)]
public string SourceId { get; set; } public string? SourceId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the date added. /// Gets or sets the date added.

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@ -18,31 +17,15 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="PersonRole"/> class. /// Initializes a new instance of the <see cref="PersonRole"/> class.
/// </summary> /// </summary>
/// <param name="type">The role type.</param> /// <param name="type">The role type.</param>
/// <param name="itemMetadata">The metadata.</param> /// <param name="person">The person.</param>
public PersonRole(PersonRoleType type, ItemMetadata itemMetadata) public PersonRole(PersonRoleType type, Person person)
{ {
Type = type; Type = type;
Person = person;
if (itemMetadata == null) Artwork = new HashSet<Artwork>();
{
throw new ArgumentNullException(nameof(itemMetadata));
}
itemMetadata.PersonRoles.Add(this);
Sources = new HashSet<MetadataProviderId>(); Sources = new HashSet<MetadataProviderId>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="PersonRole"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected PersonRole()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
@ -60,7 +43,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Role { get; set; } public string? Role { get; set; }
/// <summary> /// <summary>
/// Gets or sets the person's role type. /// Gets or sets the person's role type.
@ -80,7 +63,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
public virtual Person Person { get; set; } public virtual Person Person { get; set; }
/// <inheritdoc /> /// <inheritdoc />

@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Photo"/> class. /// Initializes a new instance of the <see cref="Photo"/> class.
/// </summary> /// </summary>
public Photo() /// <param name="library">The library.</param>
public Photo(Library library) : base(library)
{ {
PhotoMetadata = new HashSet<PhotoMetadata>(); PhotoMetadata = new HashSet<PhotoMetadata>();
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();

@ -1,5 +1,3 @@
using System;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
{ {
/// <summary> /// <summary>
@ -12,24 +10,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the photo.</param> /// <param name="title">The title or name of the photo.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="photo">The photo.</param> public PhotoMetadata(string title, string language) : base(title, language)
public PhotoMetadata(string title, string language, Photo photo) : base(title, language)
{
if (photo == null)
{
throw new ArgumentNullException(nameof(photo));
}
photo.PhotoMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="PhotoMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected PhotoMetadata()
{ {
} }
} }

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,27 +13,9 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="Rating"/> class. /// Initializes a new instance of the <see cref="Rating"/> class.
/// </summary> /// </summary>
/// <param name="value">The value.</param> /// <param name="value">The value.</param>
/// <param name="itemMetadata">The metadata.</param> public Rating(double value)
public Rating(double value, ItemMetadata itemMetadata)
{ {
Value = value; Value = value;
if (itemMetadata == null)
{
throw new ArgumentNullException(nameof(itemMetadata));
}
itemMetadata.Ratings.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="Rating"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Rating()
{
} }
/// <summary> /// <summary>
@ -67,7 +48,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// Gets or sets the rating type. /// Gets or sets the rating type.
/// If this is <c>null</c> it's the internal user rating. /// If this is <c>null</c> it's the internal user rating.
/// </summary> /// </summary>
public virtual RatingSource RatingType { get; set; } public virtual RatingSource? RatingType { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public void OnSavingChanges() public void OnSavingChanges()

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -15,28 +14,10 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="minimumValue">The minimum value.</param> /// <param name="minimumValue">The minimum value.</param>
/// <param name="maximumValue">The maximum value.</param> /// <param name="maximumValue">The maximum value.</param>
/// <param name="rating">The rating.</param> public RatingSource(double minimumValue, double maximumValue)
public RatingSource(double minimumValue, double maximumValue, Rating rating)
{ {
MinimumValue = minimumValue; MinimumValue = minimumValue;
MaximumValue = maximumValue; MaximumValue = maximumValue;
if (rating == null)
{
throw new ArgumentNullException(nameof(rating));
}
rating.RatingType = this;
}
/// <summary>
/// Initializes a new instance of the <see cref="RatingSource"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected RatingSource()
{
} }
/// <summary> /// <summary>
@ -56,7 +37,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string? Name { get; set; }
/// <summary> /// <summary>
/// Gets or sets the minimum value. /// Gets or sets the minimum value.
@ -81,7 +62,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Gets or sets the metadata source. /// Gets or sets the metadata source.
/// </summary> /// </summary>
public virtual MetadataProviderId Source { get; set; } public virtual MetadataProviderId? Source { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public void OnSavingChanges() public void OnSavingChanges()

@ -17,8 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="Release"/> class. /// Initializes a new instance of the <see cref="Release"/> class.
/// </summary> /// </summary>
/// <param name="name">The name of this release.</param> /// <param name="name">The name of this release.</param>
/// <param name="owner">The owner of this release.</param> public Release(string name)
public Release(string name, IHasReleases owner)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -27,22 +26,10 @@ namespace Jellyfin.Data.Entities.Libraries
Name = name; Name = name;
owner?.Releases.Add(this);
MediaFiles = new HashSet<MediaFile>(); MediaFiles = new HashSet<MediaFile>();
Chapters = new HashSet<Chapter>(); Chapters = new HashSet<Chapter>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Release"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Release()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
@ -58,7 +45,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 1024. /// Required, Max length = 1024.
/// </remarks> /// </remarks>
[Required]
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string Name { get; set; }

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -13,30 +12,13 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Season"/> class. /// Initializes a new instance of the <see cref="Season"/> class.
/// </summary> /// </summary>
/// <param name="series">The series.</param> /// <param name="library">The library.</param>
public Season(Series series) public Season(Library library) : base(library)
{ {
if (series == null)
{
throw new ArgumentNullException(nameof(series));
}
series.Seasons.Add(this);
Episodes = new HashSet<Episode>(); Episodes = new HashSet<Episode>();
SeasonMetadata = new HashSet<SeasonMetadata>(); SeasonMetadata = new HashSet<SeasonMetadata>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Season"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Season()
{
}
/// <summary> /// <summary>
/// Gets or sets the season number. /// Gets or sets the season number.
/// </summary> /// </summary>

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -13,24 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="season">The season.</param> public SeasonMetadata(string title, string language) : base(title, language)
public SeasonMetadata(string title, string language, Season season) : base(title, language)
{
if (season == null)
{
throw new ArgumentNullException(nameof(season));
}
season.SeasonMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="SeasonMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected SeasonMetadata()
{ {
} }
@ -42,6 +24,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Outline { get; set; } public string? Outline { get; set; }
} }
} }

@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Series"/> class. /// Initializes a new instance of the <see cref="Series"/> class.
/// </summary> /// </summary>
public Series() /// <param name="library">The library.</param>
public Series(Library library) : base(library)
{ {
DateAdded = DateTime.UtcNow; DateAdded = DateTime.UtcNow;
Seasons = new HashSet<Season>(); Seasons = new HashSet<Season>();

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@ -18,29 +17,11 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="series">The series.</param> public SeriesMetadata(string title, string language) : base(title, language)
public SeriesMetadata(string title, string language, Series series) : base(title, language)
{ {
if (series == null)
{
throw new ArgumentNullException(nameof(series));
}
series.SeriesMetadata.Add(this);
Networks = new HashSet<Company>(); Networks = new HashSet<Company>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="SeriesMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected SeriesMetadata()
{
}
/// <summary> /// <summary>
/// Gets or sets the outline. /// Gets or sets the outline.
/// </summary> /// </summary>
@ -49,7 +30,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Outline { get; set; } public string? Outline { get; set; }
/// <summary> /// <summary>
/// Gets or sets the plot. /// Gets or sets the plot.
@ -59,7 +40,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Plot { get; set; } public string? Plot { get; set; }
/// <summary> /// <summary>
/// Gets or sets the tagline. /// Gets or sets the tagline.
@ -69,7 +50,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Tagline { get; set; } public string? Tagline { get; set; }
/// <summary> /// <summary>
/// Gets or sets the country code. /// Gets or sets the country code.
@ -79,7 +60,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(2)] [MaxLength(2)]
[StringLength(2)] [StringLength(2)]
public string Country { get; set; } public string? Country { get; set; }
/// <summary> /// <summary>
/// Gets or sets a collection containing the networks. /// Gets or sets a collection containing the networks.
@ -87,7 +68,6 @@ namespace Jellyfin.Data.Entities.Libraries
public virtual ICollection<Company> Networks { get; protected set; } public virtual ICollection<Company> Networks { get; protected set; }
/// <inheritdoc /> /// <inheritdoc />
[NotMapped]
public ICollection<Company> Companies => Networks; public ICollection<Company> Companies => Networks;
} }
} }

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,30 +13,13 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Track"/> class. /// Initializes a new instance of the <see cref="Track"/> class.
/// </summary> /// </summary>
/// <param name="album">The album.</param> /// <param name="library">The library.</param>
public Track(MusicAlbum album) public Track(Library library) : base(library)
{ {
if (album == null)
{
throw new ArgumentNullException(nameof(album));
}
album.Tracks.Add(this);
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();
TrackMetadata = new HashSet<TrackMetadata>(); TrackMetadata = new HashSet<TrackMetadata>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Track"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Track()
{
}
/// <summary> /// <summary>
/// Gets or sets the track number. /// Gets or sets the track number.
/// </summary> /// </summary>

@ -1,5 +1,3 @@
using System;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
{ {
/// <summary> /// <summary>
@ -12,24 +10,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="track">The track.</param> public TrackMetadata(string title, string language) : base(title, language)
public TrackMetadata(string title, string language, Track track) : base(title, language)
{
if (track == null)
{
throw new ArgumentNullException(nameof(track));
}
track.TrackMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="TrackMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected TrackMetadata()
{ {
} }
} }

@ -24,14 +24,6 @@ namespace Jellyfin.Data.Entities
Value = value; Value = value;
} }
/// <summary>
/// Initializes a new instance of the <see cref="Permission"/> class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected Permission()
{
}
/// <summary> /// <summary>
/// Gets or sets the id of this permission. /// Gets or sets the id of this permission.
/// </summary> /// </summary>

@ -23,14 +23,6 @@ namespace Jellyfin.Data.Entities
Value = value ?? throw new ArgumentNullException(nameof(value)); Value = value ?? throw new ArgumentNullException(nameof(value));
} }
/// <summary>
/// Initializes a new instance of the <see cref="Preference"/> class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected Preference()
{
}
/// <summary> /// <summary>
/// Gets or sets the id of this preference. /// Gets or sets the id of this preference.
/// </summary> /// </summary>
@ -54,7 +46,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 65535. /// Required, Max length = 65535.
/// </remarks> /// </remarks>
[Required]
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Value { get; set; } public string Value { get; set; }

@ -51,6 +51,7 @@ namespace Jellyfin.Data.Entities
PasswordResetProviderId = passwordResetProviderId; PasswordResetProviderId = passwordResetProviderId;
AccessSchedules = new HashSet<AccessSchedule>(); AccessSchedules = new HashSet<AccessSchedule>();
DisplayPreferences = new HashSet<DisplayPreferences>();
ItemDisplayPreferences = new HashSet<ItemDisplayPreferences>(); ItemDisplayPreferences = new HashSet<ItemDisplayPreferences>();
// Groups = new HashSet<Group>(); // Groups = new HashSet<Group>();
Permissions = new HashSet<Permission>(); Permissions = new HashSet<Permission>();
@ -77,14 +78,6 @@ namespace Jellyfin.Data.Entities
AddDefaultPreferences(); AddDefaultPreferences();
} }
/// <summary>
/// Initializes a new instance of the <see cref="User"/> class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected User()
{
}
/// <summary> /// <summary>
/// Gets or sets the Id of the user. /// Gets or sets the Id of the user.
/// </summary> /// </summary>
@ -100,7 +93,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 255. /// Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string Username { get; set; } public string Username { get; set; }
@ -113,7 +105,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Password { get; set; } public string? Password { get; set; }
/// <summary> /// <summary>
/// Gets or sets the user's easy password, or <c>null</c> if none is set. /// Gets or sets the user's easy password, or <c>null</c> if none is set.
@ -123,7 +115,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string EasyPassword { get; set; } public string? EasyPassword { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the user must update their password. /// Gets or sets a value indicating whether the user must update their password.
@ -141,7 +133,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string AudioLanguagePreference { get; set; } public string? AudioLanguagePreference { get; set; }
/// <summary> /// <summary>
/// Gets or sets the authentication provider id. /// Gets or sets the authentication provider id.
@ -149,7 +141,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 255. /// Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string AuthenticationProviderId { get; set; } public string AuthenticationProviderId { get; set; }
@ -160,7 +151,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 255. /// Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string PasswordResetProviderId { get; set; } public string PasswordResetProviderId { get; set; }
@ -217,7 +207,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string SubtitleLanguagePreference { get; set; } public string? SubtitleLanguagePreference { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether missing episodes should be displayed. /// Gets or sets a value indicating whether missing episodes should be displayed.
@ -312,7 +302,7 @@ namespace Jellyfin.Data.Entities
/// Gets or sets the user's profile image. Can be <c>null</c>. /// Gets or sets the user's profile image. Can be <c>null</c>.
/// </summary> /// </summary>
// [ForeignKey("UserId")] // [ForeignKey("UserId")]
public virtual ImageInfo ProfileImage { get; set; } public virtual ImageInfo? ProfileImage { get; set; }
/// <summary> /// <summary>
/// Gets or sets the user's display preferences. /// Gets or sets the user's display preferences.
@ -320,8 +310,7 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required] public virtual ICollection<DisplayPreferences> DisplayPreferences { get; set; }
public virtual DisplayPreferences DisplayPreferences { get; set; }
/// <summary> /// <summary>
/// Gets or sets the level of sync play permissions this user has. /// Gets or sets the level of sync play permissions this user has.

@ -2,7 +2,7 @@
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
namespace Jellyfin.Data namespace Jellyfin.Data.Interfaces
{ {
/// <summary> /// <summary>
/// An abstraction representing an entity that has permissions. /// An abstraction representing an entity that has permissions.

@ -7,6 +7,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisMode>AllEnabledByDefault</AnalysisMode> <AnalysisMode>AllEnabledByDefault</AnalysisMode>
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
<Nullable>enable</Nullable>
<PublishRepositoryUrl>true</PublishRepositoryUrl> <PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources> <EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols> <IncludeSymbols>true</IncludeSymbols>
@ -38,8 +39,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.3" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -86,7 +86,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
return name; return name;
} }
private static string? GetPlaybackNotificationType(string mediaType) private static string GetPlaybackNotificationType(string mediaType)
{ {
if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
{ {
@ -98,7 +98,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
return NotificationType.VideoPlayback.ToString(); return NotificationType.VideoPlayback.ToString();
} }
return null; return "Playback";
} }
} }
} }

@ -27,6 +27,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Linq.Async" Version="5.0.0" /> <PackageReference Include="System.Linq.Async" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

@ -184,8 +184,8 @@ namespace Jellyfin.Server.Implementations.Users
var user = new User( var user = new User(
name, name,
_defaultAuthenticationProvider.GetType().FullName, _defaultAuthenticationProvider.GetType().FullName!,
_defaultPasswordResetProvider.GetType().FullName) _defaultPasswordResetProvider.GetType().FullName!)
{ {
InternalId = max + 1 InternalId = max + 1
}; };
@ -444,7 +444,7 @@ namespace Jellyfin.Server.Implementations.Users
{ {
var providerId = authenticationProvider.GetType().FullName; var providerId = authenticationProvider.GetType().FullName;
if (!string.Equals(providerId, user.AuthenticationProviderId, StringComparison.OrdinalIgnoreCase)) if (providerId != null && !string.Equals(providerId, user.AuthenticationProviderId, StringComparison.OrdinalIgnoreCase))
{ {
user.AuthenticationProviderId = providerId; user.AuthenticationProviderId = providerId;
await UpdateUserAsync(user).ConfigureAwait(false); await UpdateUserAsync(user).ConfigureAwait(false);

@ -1,7 +1,5 @@
using System; using System;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq;
using Emby.Server.Implementations.Data; using Emby.Server.Implementations.Data;
using Emby.Server.Implementations.Serialization; using Emby.Server.Implementations.Serialization;
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
@ -104,7 +102,7 @@ namespace Jellyfin.Server.Migrations.Routines
_ => policy.LoginAttemptsBeforeLockout _ => policy.LoginAttemptsBeforeLockout
}; };
var user = new User(mockup.Name, policy.AuthenticationProviderId, policy.PasswordResetProviderId) var user = new User(mockup.Name, policy.AuthenticationProviderId!, policy.PasswordResetProviderId!)
{ {
Id = entry[1].ReadGuidFromBlob(), Id = entry[1].ReadGuidFromBlob(),
InternalId = entry[0].ToInt64(), InternalId = entry[0].ToInt64(),

@ -61,7 +61,7 @@ namespace MediaBrowser.Controller.Drawing
string GetImageCacheTag(BaseItem item, ChapterInfo info); string GetImageCacheTag(BaseItem item, ChapterInfo info);
string GetImageCacheTag(User user); string? GetImageCacheTag(User user);
/// <summary> /// <summary>
/// Processes the image. /// Processes the image.

@ -26,8 +26,8 @@ namespace Jellyfin.Api.Tests
{ {
var user = new User( var user = new User(
"jellyfin", "jellyfin",
typeof(DefaultAuthenticationProvider).FullName, typeof(DefaultAuthenticationProvider).FullName!,
typeof(DefaultPasswordResetProvider).FullName); typeof(DefaultPasswordResetProvider).FullName!);
// Set administrator flag. // Set administrator flag.
user.SetPermission(PermissionKind.IsAdministrator, role.Equals(UserRoles.Administrator, StringComparison.OrdinalIgnoreCase)); user.SetPermission(PermissionKind.IsAdministrator, role.Equals(UserRoles.Administrator, StringComparison.OrdinalIgnoreCase));

Loading…
Cancel
Save