fix: open the connection when using SqliteConnection directly

This commit is contained in:
cvium 2023-09-16 07:25:29 +02:00
parent 5a71b8beed
commit ba928d872e
5 changed files with 8 additions and 2 deletions

View File

@ -64,6 +64,8 @@ namespace Jellyfin.Server.Migrations.Routines
using (var connection = new SqliteConnection($"Filename={Path.Combine(dataPath, DbFilename)}")) using (var connection = new SqliteConnection($"Filename={Path.Combine(dataPath, DbFilename)}"))
{ {
using var userDbConnection = new SqliteConnection($"Filename={Path.Combine(dataPath, "users.db")}"); using var userDbConnection = new SqliteConnection($"Filename={Path.Combine(dataPath, "users.db")}");
connection.Open();
userDbConnection.Open();
_logger.LogWarning("Migrating the activity database may take a while, do not stop Jellyfin."); _logger.LogWarning("Migrating the activity database may take a while, do not stop Jellyfin.");
using var dbContext = _provider.CreateDbContext(); using var dbContext = _provider.CreateDbContext();

View File

@ -58,6 +58,7 @@ namespace Jellyfin.Server.Migrations.Routines
var dataPath = _appPaths.DataPath; var dataPath = _appPaths.DataPath;
using (var connection = new SqliteConnection($"Filename={Path.Combine(dataPath, DbFilename)}")) using (var connection = new SqliteConnection($"Filename={Path.Combine(dataPath, DbFilename)}"))
{ {
connection.Open();
using var dbContext = _dbProvider.CreateDbContext(); using var dbContext = _dbProvider.CreateDbContext();
var authenticatedDevices = connection.Query("SELECT * FROM Tokens"); var authenticatedDevices = connection.Query("SELECT * FROM Tokens");

View File

@ -66,7 +66,8 @@ namespace Jellyfin.Server.Migrations.Routines
// Migrate parental rating strings to new levels // Migrate parental rating strings to new levels
_logger.LogInformation("Recalculating parental rating levels based on rating string."); _logger.LogInformation("Recalculating parental rating levels based on rating string.");
using (var connection = new SqliteConnection($"Filename={dbPath}")) using var connection = new SqliteConnection($"Filename={dbPath}");
connection.Open();
using (var transaction = connection.BeginTransaction()) using (var transaction = connection.BeginTransaction())
{ {
var queryResult = connection.Query("SELECT DISTINCT OfficialRating FROM TypedBaseItems"); var queryResult = connection.Query("SELECT DISTINCT OfficialRating FROM TypedBaseItems");

View File

@ -66,6 +66,7 @@ namespace Jellyfin.Server.Migrations.Routines
using (var connection = new SqliteConnection($"Filename={Path.Combine(dataPath, DbFilename)}")) using (var connection = new SqliteConnection($"Filename={Path.Combine(dataPath, DbFilename)}"))
{ {
connection.Open();
var dbContext = _provider.CreateDbContext(); var dbContext = _provider.CreateDbContext();
var queryResult = connection.Query("SELECT * FROM LocalUsersv2"); var queryResult = connection.Query("SELECT * FROM LocalUsersv2");

View File

@ -38,7 +38,8 @@ namespace Jellyfin.Server.Migrations.Routines
{ {
var dataPath = _paths.DataPath; var dataPath = _paths.DataPath;
var dbPath = Path.Combine(dataPath, DbFilename); var dbPath = Path.Combine(dataPath, DbFilename);
using (var connection = new SqliteConnection($"Filename={dbPath}")) using var connection = new SqliteConnection($"Filename={dbPath}");
connection.Open();
using (var transaction = connection.BeginTransaction()) using (var transaction = connection.BeginTransaction())
{ {
// Query the database for the ids of duplicate extras // Query the database for the ids of duplicate extras