aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2026-09-05 07:34:38 +0200
committerShadowghost <Ghost_of_Stone@web.de>2026-09-05 07:36:17 +0200
commit5465e0c69423506d6836f2a6b8aacfce8cb0501e (patch)
tree4a77740d2fedd93e4fd7ba6abefa65be630a754c /src
parent0b5bbb528af08d950bc9887b5a1114888820688b (diff)
Optimize the database on startup instead of before shutdown
Diffstat (limited to 'src')
-rw-r--r--src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs2
-rw-r--r--src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/SqliteDatabaseProvider.cs14
2 files changed, 3 insertions, 13 deletions
diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs
index 87d87e92b8..a7b2aa493b 100644
--- a/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs
+++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs
@@ -38,7 +38,7 @@ public interface IJellyfinDatabaseProvider
/// <summary>
/// If supported this should run any periodic maintaince tasks, reclaiming unused space and refreshing the query
- /// planner statistics. Also used after migrations have modified the database.
+ /// planner statistics. Also runs on startup once all migrations have been applied.
/// </summary>
/// <param name="cancellationToken">The token to abort the operation.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
diff --git a/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/SqliteDatabaseProvider.cs b/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/SqliteDatabaseProvider.cs
index dff834bfec..6103ecd992 100644
--- a/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/SqliteDatabaseProvider.cs
+++ b/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/SqliteDatabaseProvider.cs
@@ -124,21 +124,11 @@ public sealed class SqliteDatabaseProvider : IJellyfinDatabaseProvider
}
/// <inheritdoc/>
- public async Task RunShutdownTask(CancellationToken cancellationToken)
+ public Task RunShutdownTask(CancellationToken cancellationToken)
{
- if (DbContextFactory is null)
- {
- return;
- }
-
// Run before disposing the application
- var context = await DbContextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using (context.ConfigureAwait(false))
- {
- await context.Database.ExecuteSqlRawAsync("PRAGMA optimize", cancellationToken).ConfigureAwait(false);
- }
-
SqliteConnection.ClearAllPools();
+ return Task.CompletedTask;
}
/// <inheritdoc/>