aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
diff options
context:
space:
mode:
authorJPVenson <github@jpb.email>2025-01-27 16:35:46 +0000
committerJPVenson <github@jpb.email>2025-01-27 16:35:46 +0000
commit9d1c4ea169a15d580923aefb0ec43c2b6be5b3a6 (patch)
tree609e013c4c4fd5ca6f151cca2950520bfb50df83 /Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
parentaa811eb1e3c78bdf8f4a751311c1bb6d639e851e (diff)
Fixed DbContext usage on Provider
Diffstat (limited to 'Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs')
-rw-r--r--Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs19
1 files changed, 11 insertions, 8 deletions
diff --git a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
index e48f4ce10..1b0dbbe10 100644
--- a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
+++ b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
+using Jellyfin.Database.Providers.SqLite;
using Jellyfin.Server.Implementations.DatabaseConfiguration;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Configuration;
@@ -17,14 +18,15 @@ namespace Jellyfin.Server.Implementations.Extensions;
/// </summary>
public static class ServiceCollectionExtensions
{
+ private static IEnumerable<Type> DatabaseProviderTypes()
+ {
+ yield return typeof(SqliteDatabaseProvider);
+ }
+
private static IDictionary<string, JellyfinDbProviderFactory> GetSupportedDbProviders()
{
var items = new Dictionary<string, JellyfinDbProviderFactory>();
- foreach (var providerType in AppDomain
- .CurrentDomain
- .GetAssemblies()
- .SelectMany(f => f.GetTypes())
- .Where(e => e.IsClass && typeof(IJellyfinDatabaseProvider).IsAssignableFrom(e)))
+ foreach (var providerType in DatabaseProviderTypes())
{
var keyAttribute = providerType.GetCustomAttribute<JellyfinDatabaseProviderKeyAttribute>();
if (keyAttribute is null || string.IsNullOrWhiteSpace(keyAttribute.DatabaseProviderKey))
@@ -51,15 +53,16 @@ public static class ServiceCollectionExtensions
var providers = GetSupportedDbProviders();
JellyfinDbProviderFactory? providerFactory = null;
- if (efCoreConfiguration is null)
+ if (efCoreConfiguration?.DatabaseType is null)
{
// when nothing is setup via new Database configuration, fallback to SqLite with default settings.
efCoreConfiguration = new DatabaseConfigurationOptions()
{
- DatabaseType = "SqLite",
+ DatabaseType = "Jellyfin-SqLite",
};
}
- else if (!providers.TryGetValue(efCoreConfiguration.DatabaseType, out providerFactory!))
+
+ if (!providers.TryGetValue(efCoreConfiguration.DatabaseType, out providerFactory!))
{
throw new InvalidOperationException($"Jellyfin cannot find the database provider of type '{efCoreConfiguration.DatabaseType}'. Supported types are {string.Join(", ", providers.Keys)}");
}