mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-17 13:10:28 +01:00
Fixed shutdown behavior
This commit is contained in:
@@ -8,7 +8,7 @@ namespace Jellyfin.Server.Implementations;
|
||||
/// <summary>
|
||||
/// Defines the type and extension points for multi database support.
|
||||
/// </summary>
|
||||
public interface IJellyfinDatabaseProvider : IAsyncDisposable
|
||||
public interface IJellyfinDatabaseProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets the Database Factory when initialisaition is done.
|
||||
@@ -33,4 +33,11 @@ public interface IJellyfinDatabaseProvider : IAsyncDisposable
|
||||
/// <param name="cancellationToken">The token to abort the operation.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
Task RunScheduledOptimisation(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// If supported this should perform any actions that are required on stopping the jellyfin server.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The token that will be used to abort the operation.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
Task RunShutdownTask(CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ public sealed class PgSqlDatabaseProvider : IJellyfinDatabaseProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ValueTask DisposeAsync()
|
||||
public Task RunShutdownTask(CancellationToken cancellationToken)
|
||||
{
|
||||
return ValueTask.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ public sealed class SqliteDatabaseProvider : IJellyfinDatabaseProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async ValueTask DisposeAsync()
|
||||
public async Task RunShutdownTask(CancellationToken cancellationToken)
|
||||
{
|
||||
// Run before disposing the application
|
||||
var context = await DbContextFactory!.CreateDbContextAsync().ConfigureAwait(false);
|
||||
var context = await DbContextFactory!.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
|
||||
await using (context.ConfigureAwait(false))
|
||||
{
|
||||
await context.Database.ExecuteSqlRawAsync("PRAGMA optimize").ConfigureAwait(false);
|
||||
await context.Database.ExecuteSqlRawAsync("PRAGMA optimize", cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
SqliteConnection.ClearAllPools();
|
||||
|
||||
Reference in New Issue
Block a user