Updated code to correct build errors for Jelyfin.Data and Jellyfin.Database.Implementations

This commit is contained in:
2026-02-19 15:51:56 -05:00
parent f47555f2aa
commit d5fdbec943
317 changed files with 17235 additions and 3473 deletions
@@ -2,6 +2,8 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1202
namespace Jellyfin.Database.Implementations;
using System;
@@ -17,7 +19,6 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Logging;
/// <inheritdoc/>
/// <summary>
/// Initializes a new instance of the <see cref="JellyfinDbContext"/> class.
@@ -28,150 +29,156 @@ using Microsoft.Extensions.Logging;
/// <param name="entityFrameworkCoreLocking">The locking behavior.</param>
public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILogger<JellyfinDbContext> logger, IJellyfinDatabaseProvider jellyfinDatabaseProvider, IEntityFrameworkCoreLockingBehavior entityFrameworkCoreLocking) : DbContext(options)
{
private static readonly Action<ILogger, Exception?> SaveChangesError =
LoggerMessage.Define(
LogLevel.Error,
new EventId(1, nameof(SaveChanges)),
"Error trying to save changes.");
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the access schedules.
/// </summary>
public DbSet<AccessSchedule> AccessSchedules => Set<AccessSchedule>();
public DbSet<AccessSchedule> AccessSchedules => this.Set<AccessSchedule>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the activity logs.
/// </summary>
public DbSet<ActivityLog> ActivityLogs => Set<ActivityLog>();
public DbSet<ActivityLog> ActivityLogs => this.Set<ActivityLog>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the API keys.
/// </summary>
public DbSet<ApiKey> ApiKeys => Set<ApiKey>();
public DbSet<ApiKey> ApiKeys => this.Set<ApiKey>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the devices.
/// </summary>
public DbSet<Device> Devices => Set<Device>();
public DbSet<Device> Devices => this.Set<Device>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the device options.
/// </summary>
public DbSet<DeviceOptions> DeviceOptions => Set<DeviceOptions>();
public DbSet<DeviceOptions> DeviceOptions => this.Set<DeviceOptions>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the display preferences.
/// </summary>
public DbSet<DisplayPreferences> DisplayPreferences => Set<DisplayPreferences>();
public DbSet<DisplayPreferences> DisplayPreferences => this.Set<DisplayPreferences>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the image infos.
/// </summary>
public DbSet<ImageInfo> ImageInfos => Set<ImageInfo>();
public DbSet<ImageInfo> ImageInfos => this.Set<ImageInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the item display preferences.
/// </summary>
public DbSet<ItemDisplayPreferences> ItemDisplayPreferences => Set<ItemDisplayPreferences>();
public DbSet<ItemDisplayPreferences> ItemDisplayPreferences => this.Set<ItemDisplayPreferences>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the custom item display preferences.
/// </summary>
public DbSet<CustomItemDisplayPreferences> CustomItemDisplayPreferences => Set<CustomItemDisplayPreferences>();
public DbSet<CustomItemDisplayPreferences> CustomItemDisplayPreferences => this.Set<CustomItemDisplayPreferences>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the permissions.
/// </summary>
public DbSet<Permission> Permissions => Set<Permission>();
public DbSet<Permission> Permissions => this.Set<Permission>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the preferences.
/// </summary>
public DbSet<Preference> Preferences => Set<Preference>();
public DbSet<Preference> Preferences => this.Set<Preference>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the users.
/// </summary>
public DbSet<User> Users => Set<User>();
public DbSet<User> Users => this.Set<User>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the trickplay metadata.
/// </summary>
public DbSet<TrickplayInfo> TrickplayInfos => Set<TrickplayInfo>();
public DbSet<TrickplayInfo> TrickplayInfos => this.Set<TrickplayInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the media segments.
/// </summary>
public DbSet<MediaSegment> MediaSegments => Set<MediaSegment>();
public DbSet<MediaSegment> MediaSegments => this.Set<MediaSegment>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the user data.
/// </summary>
public DbSet<UserData> UserData => Set<UserData>();
public DbSet<UserData> UserData => this.Set<UserData>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the user data.
/// </summary>
public DbSet<AncestorId> AncestorIds => Set<AncestorId>();
public DbSet<AncestorId> AncestorIds => this.Set<AncestorId>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the user data.
/// </summary>
public DbSet<AttachmentStreamInfo> AttachmentStreamInfos => Set<AttachmentStreamInfo>();
public DbSet<AttachmentStreamInfo> AttachmentStreamInfos => this.Set<AttachmentStreamInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the user data.
/// </summary>
public DbSet<BaseItemEntity> BaseItems => Set<BaseItemEntity>();
public DbSet<BaseItemEntity> BaseItems => this.Set<BaseItemEntity>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the user data.
/// </summary>
public DbSet<Chapter> Chapters => Set<Chapter>();
public DbSet<Chapter> Chapters => this.Set<Chapter>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<ItemValue> ItemValues => Set<ItemValue>();
public DbSet<ItemValue> ItemValues => this.Set<ItemValue>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<ItemValueMap> ItemValuesMap => Set<ItemValueMap>();
public DbSet<ItemValueMap> ItemValuesMap => this.Set<ItemValueMap>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<MediaStreamInfo> MediaStreamInfos => Set<MediaStreamInfo>();
public DbSet<MediaStreamInfo> MediaStreamInfos => this.Set<MediaStreamInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<People> Peoples => Set<People>();
public DbSet<People> Peoples => this.Set<People>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<PeopleBaseItemMap> PeopleBaseItemMap => Set<PeopleBaseItemMap>();
public DbSet<PeopleBaseItemMap> PeopleBaseItemMap => this.Set<PeopleBaseItemMap>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the referenced Providers with ids.
/// </summary>
public DbSet<BaseItemProvider> BaseItemProviders => Set<BaseItemProvider>();
public DbSet<BaseItemProvider> BaseItemProviders => this.Set<BaseItemProvider>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<BaseItemImageInfo> BaseItemImageInfos => Set<BaseItemImageInfo>();
public DbSet<BaseItemImageInfo> BaseItemImageInfos => this.Set<BaseItemImageInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<BaseItemMetadataField> BaseItemMetadataFields => Set<BaseItemMetadataField>();
public DbSet<BaseItemMetadataField> BaseItemMetadataFields => this.Set<BaseItemMetadataField>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<BaseItemTrailerType> BaseItemTrailerTypes => Set<BaseItemTrailerType>();
public DbSet<BaseItemTrailerType> BaseItemTrailerTypes => this.Set<BaseItemTrailerType>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<KeyframeData> KeyframeData => Set<KeyframeData>();
public DbSet<KeyframeData> KeyframeData => this.Set<KeyframeData>();
/*public DbSet<Artwork> Artwork => Set<Artwork>();
@@ -262,7 +269,7 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
bool acceptAllChangesOnSuccess,
CancellationToken cancellationToken = default)
{
HandleConcurrencyToken();
this.HandleConcurrencyToken();
try
{
@@ -275,7 +282,7 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
}
catch (Exception e)
{
logger.LogError(e, "Error trying to save changes.");
SaveChangesError(logger, e);
throw;
}
}
@@ -283,7 +290,7 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
/// <inheritdoc/>
public override int SaveChanges(bool acceptAllChangesOnSuccess) // SaveChanges(bool) is beeing called by SaveChanges() with default to false.
{
HandleConcurrencyToken();
this.HandleConcurrencyToken();
try
{
@@ -296,14 +303,14 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
}
catch (Exception e)
{
logger.LogError(e, "Error trying to save changes.");
SaveChangesError(logger, e);
throw;
}
}
private void HandleConcurrencyToken()
{
foreach (var saveEntity in ChangeTracker.Entries()
foreach (var saveEntity in this.ChangeTracker.Entries()
.Where(e => e.State == EntityState.Modified)
.Select(entry => entry.Entity)
.OfType<IHasConcurrencyToken>())
@@ -318,6 +325,8 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
jellyfinDatabaseProvider.OnModelCreating(modelBuilder);
base.OnModelCreating(modelBuilder);
ArgumentNullException.ThrowIfNull(modelBuilder);
// Configuration for each entity is in its own class inside 'ModelConfiguration'.
modelBuilder.ApplyConfigurationsFromAssembly(typeof(JellyfinDbContext).Assembly);
}