diff options
| author | crobibero <cody@robibe.ro> | 2025-11-02 21:58:43 -0500 |
|---|---|---|
| committer | Joshua M. Boniface <joshua@boniface.me> | 2025-11-02 21:58:43 -0500 |
| commit | c9d93b0745381154d81023e0602bb8bbd7566418 (patch) | |
| tree | 54c44460f645487899fc00185019c3734f19783f /Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs | |
| parent | 1ccd10863e24485978a2f5fd7650b2bcf42168d3 (diff) | |
Backport pull request #15322 from jellyfin/release-10.11.z
Fix legacy migration file checks
Original-merge: da254ee968deca4d47f0f5d1164c5e883745ac60
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Joshua M. Boniface <joshua@boniface.me>
Diffstat (limited to 'Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs')
| -rw-r--r-- | Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs index c6699c21d..0de775e03 100644 --- a/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs +++ b/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs @@ -50,9 +50,28 @@ namespace Jellyfin.Server.Migrations.Routines public void Perform() { var dataPath = _appPaths.DataPath; - using (var connection = new SqliteConnection($"Filename={Path.Combine(dataPath, DbFilename)}")) + var dbFilePath = Path.Combine(dataPath, DbFilename); + + if (!File.Exists(dbFilePath)) + { + _logger.LogWarning("{Path} doesn't exist, nothing to migrate", dbFilePath); + return; + } + + using (var connection = new SqliteConnection($"Filename={dbFilePath}")) { connection.Open(); + + var tableQuery = connection.Query("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='Tokens';"); + foreach (var row in tableQuery) + { + if (row.GetInt32(0) == 0) + { + _logger.LogWarning("Table 'Tokens' doesn't exist in {Path}, nothing to migrate", dbFilePath); + return; + } + } + using var dbContext = _dbProvider.CreateDbContext(); var authenticatedDevices = connection.Query("SELECT * FROM Tokens"); |
