Fixed: (Database) Improve Version detection

pull/1618/head
Bogdan 2 years ago committed by GitHub
parent fbea5bbc06
commit 788fa6d96a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,6 @@
using System; using System;
using System.Data; using System.Data;
using System.Data.Common;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Dapper; using Dapper;
using NLog; using NLog;
@ -56,26 +57,13 @@ namespace NzbDrone.Core.Datastore
{ {
get get
{ {
using (var db = _datamapperFactory()) using var db = _datamapperFactory();
{ var dbConnection = db as DbConnection;
string version; var version = Regex.Replace(dbConnection.ServerVersion, @"\(.*?\)", "");
try
{
version = db.QueryFirstOrDefault<string>("SHOW server_version");
//Postgres can return extra info about operating system on version call, ignore this
version = Regex.Replace(version, @"\(.*?\)", "");
}
catch
{
version = db.QueryFirstOrDefault<string>("SELECT sqlite_version()");
}
return new Version(version); return new Version(version);
} }
} }
}
public int Migration public int Migration
{ {

Loading…
Cancel
Save