diff options
Diffstat (limited to 'src/slskd/Program.cs')
| -rw-r--r-- | src/slskd/Program.cs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index d31f6d0d..35ed87fc 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -596,25 +596,23 @@ namespace slskd // wire up all of the connection strings we'll use. this is somewhat annoying but necessary because of the // intersection of run-time options (volatile, non-volatile) and ORM/mappers in use (EF, Dapper) - var databases = new[] { "search", "transfers", "messaging", "events" }; - - var connectionStrings = new ConnectionStringDictionary(databases + var connectionStringDictionary = new ConnectionStringDictionary(Database.List .Select(database => { var connStr = OptionsAtStartup.Flags.Volatile ? $"Data Source=file:{database}?mode=memory;Cache=shared;Pooling=True;" : $"Data Source={Path.Combine(DataDirectory, $"{database}.db")};Cache=shared;Pooling=True;"; - return new KeyValuePair<string, ConnectionString>(database, connStr); + return new KeyValuePair<Database, ConnectionString>(database, connStr); }) .ToDictionary(x => x.Key, x => x.Value)); - services.AddDbContext<SearchDbContext>(connectionStrings["search"]); - services.AddDbContext<TransfersDbContext>(connectionStrings["transfers"]); - services.AddDbContext<MessagingDbContext>(connectionStrings["messaging"]); - services.AddDbContext<EventsDbContext>(connectionStrings["events"]); + services.AddDbContext<SearchDbContext>(connectionStringDictionary[Database.Search]); + services.AddDbContext<TransfersDbContext>(connectionStringDictionary[Database.Transfers]); + services.AddDbContext<MessagingDbContext>(connectionStringDictionary[Database.Messaging]); + services.AddDbContext<EventsDbContext>(connectionStringDictionary[Database.Events]); - services.AddSingleton<ConnectionStringDictionary>(connectionStrings); + services.AddSingleton<ConnectionStringDictionary>(connectionStringDictionary); if (!OptionsAtStartup.Flags.Volatile) { @@ -622,7 +620,7 @@ namespace slskd // bootup process. the presence of a Migrator instance in DI determines whether a migration is needed. // it's important that we keep this list of databases in sync with those used by the application; anything // not in this list will not be able to be migrated. - services.AddSingleton<Migrator>(_ => new Migrator(databases)); + services.AddSingleton<Migrator>(_ => new Migrator(databases: connectionStringDictionary)); } services.AddSingleton<EventService>(); |
