diff --git a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs index 59b7e143c1..d48ab704f6 100644 --- a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs +++ b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs @@ -464,6 +464,16 @@ internal class MigrateLibraryDb : IDatabaseMigrationRoutine SqliteConnection.ClearAllPools(); + using (var checkpointConnection = new SqliteConnection($"Filename={libraryDbPath}")) + { + checkpointConnection.Open(); + using var cmd = checkpointConnection.CreateCommand(); + cmd.CommandText = "PRAGMA wal_checkpoint(TRUNCATE);"; + cmd.ExecuteNonQuery(); + } + + SqliteConnection.ClearAllPools(); + _logger.LogInformation("Move {0} to {1}.", libraryDbPath, libraryDbPath + ".old"); File.Move(libraryDbPath, libraryDbPath + ".old", true); }