Skip to content

Commit

Permalink
Fixed: Database type when PG host contains ".db" (#4435)
Browse files Browse the repository at this point in the history
Previously was looking for a ".db" in the connection string, which is
the typical sqlite filename. The problem is if your connection string has a
.db anywhere in it, such as postgres.db.internal it'll think its a
sqlite file

Solution borrowed from sonarr:

https://github.com/Sonarr/Sonarr/blob/develop/src/NzbDrone.Core/Datastore/Database.cs#L43
  • Loading branch information
halkeye committed Jan 12, 2024
1 parent 5661a0a commit a9c19a8
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/NzbDrone.Core/Datastore/Database.cs
@@ -1,5 +1,6 @@
using System;
using System;
using System.Data;
using System.Data.SQLite;
using System.Text.RegularExpressions;
using Dapper;
using NLog;
Expand Down Expand Up @@ -40,14 +41,7 @@ public DatabaseType DatabaseType
{
using (var db = _datamapperFactory())
{
if (db.ConnectionString.Contains(".db"))
{
return DatabaseType.SQLite;
}
else
{
return DatabaseType.PostgreSQL;
}
return db is SQLiteConnection ? DatabaseType.SQLite : DatabaseType.PostgreSQL;
}
}
}
Expand Down

0 comments on commit a9c19a8

Please sign in to comment.