mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Fixed WAL lock on program exit
This commit is contained in:
parent
741397f1be
commit
bdab5e549e
@ -13,6 +13,7 @@ using Jellyfin.Server.Implementations;
|
|||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Data.Sqlite;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@ -193,6 +194,7 @@ namespace Jellyfin.Server
|
|||||||
// Don't throw additional exception if startup failed.
|
// Don't throw additional exception if startup failed.
|
||||||
if (appHost.ServiceProvider is not null)
|
if (appHost.ServiceProvider is not null)
|
||||||
{
|
{
|
||||||
|
var isSqlite = false;
|
||||||
_logger.LogInformation("Running query planner optimizations in the database... This might take a while");
|
_logger.LogInformation("Running query planner optimizations in the database... This might take a while");
|
||||||
// Run before disposing the application
|
// Run before disposing the application
|
||||||
var context = await appHost.ServiceProvider.GetRequiredService<IDbContextFactory<JellyfinDbContext>>().CreateDbContextAsync().ConfigureAwait(false);
|
var context = await appHost.ServiceProvider.GetRequiredService<IDbContextFactory<JellyfinDbContext>>().CreateDbContextAsync().ConfigureAwait(false);
|
||||||
@ -200,9 +202,15 @@ namespace Jellyfin.Server
|
|||||||
{
|
{
|
||||||
if (context.Database.IsSqlite())
|
if (context.Database.IsSqlite())
|
||||||
{
|
{
|
||||||
|
isSqlite = true;
|
||||||
await context.Database.ExecuteSqlRawAsync("PRAGMA optimize").ConfigureAwait(false);
|
await context.Database.ExecuteSqlRawAsync("PRAGMA optimize").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSqlite)
|
||||||
|
{
|
||||||
|
SqliteConnection.ClearAllPools();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
host?.Dispose();
|
host?.Dispose();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user