Merge pull request #10455 from cvium/dispose_dbcontext

This commit is contained in:
Bond-009 2023-10-23 23:07:02 +02:00 committed by GitHub
commit d977f48b5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -8,6 +8,10 @@
<!-- Code analysers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="IDisposableAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
using MediaBrowser.Controller;
using Microsoft.EntityFrameworkCore;
@ -13,7 +14,7 @@ namespace Jellyfin.Server.Implementations.Users
/// <summary>
/// Manages the storage and retrieval of display preferences through Entity Framework.
/// </summary>
public class DisplayPreferencesManager : IDisplayPreferencesManager
public sealed class DisplayPreferencesManager : IDisplayPreferencesManager, IAsyncDisposable
{
private readonly JellyfinDbContext _dbContext;
@ -97,5 +98,11 @@ namespace Jellyfin.Server.Implementations.Users
{
_dbContext.SaveChanges();
}
/// <inheritdoc />
public async ValueTask DisposeAsync()
{
await _dbContext.DisposeAsync().ConfigureAwait(false);
}
}
}