diff options
| author | Taylor Southwick <tasou@microsoft.com> | 2026-10-07 11:04:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-10-07 20:04:55 +0200 |
| commit | 284997ebe28678ebca971f9f64fcfe02976ed937 (patch) | |
| tree | 96723c252e112b8d0094f516b4bb9740e79ff92f | |
| parent | 266434831b67ba828a874178b5e67dcaea9d65a2 (diff) | |
Merge pull request #17565 from twsouthwick/use-datasource
Use DataSource for sqlite db path
| -rw-r--r-- | src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/SqliteDatabaseProvider.cs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/SqliteDatabaseProvider.cs b/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/SqliteDatabaseProvider.cs index a3fbe42e02..f0b44d6130 100644 --- a/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/SqliteDatabaseProvider.cs +++ b/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/SqliteDatabaseProvider.cs @@ -287,7 +287,7 @@ public sealed class SqliteDatabaseProvider : IJellyfinDatabaseProvider /// <inheritdoc /> public async Task<string> MigrationBackupFast(CancellationToken cancellationToken) { - var path = Path.Combine(_applicationPaths.DataPath, "jellyfin.db"); + var path = GetDatabasePath(); var backupFolder = Path.Combine(_applicationPaths.DataPath, BackupFolderName); Directory.CreateDirectory(backupFolder); @@ -317,7 +317,7 @@ public sealed class SqliteDatabaseProvider : IJellyfinDatabaseProvider { // ensure there are absolutely no dangling Sqlite connections. SqliteConnection.ClearAllPools(); - var path = Path.Combine(_applicationPaths.DataPath, "jellyfin.db"); + var path = GetDatabasePath(); var backupFile = Path.Combine(_applicationPaths.DataPath, BackupFolderName, $"{key}_jellyfin.db"); if (!File.Exists(backupFile)) @@ -390,6 +390,17 @@ public sealed class SqliteDatabaseProvider : IJellyfinDatabaseProvider return Task.CompletedTask; } + private string GetDatabasePath() + { + if (DbContextFactory is null) + { + throw new InvalidOperationException("The database provider has not been initialized."); + } + + using var dbContext = DbContextFactory.CreateDbContext(); + return dbContext.Database.GetDbConnection().DataSource; + } + /// <inheritdoc/> public async Task PurgeDatabase(JellyfinDbContext dbContext, IEnumerable<string>? tableNames) { |
