1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00
Sonarr/NzbDrone.Core/Datastore/ObjectDbFactory.cs

43 lines
1.1 KiB
C#
Raw Normal View History

using System.Linq;
2013-02-17 04:52:40 +03:00
using NzbDrone.Common;
using Sqo;
namespace NzbDrone.Core.Datastore
{
public interface IObjectDbFactory
{
IObjectDatabase Create(string dbPath = null);
2013-02-17 04:52:40 +03:00
}
public class SiaqoDbFactory : IObjectDbFactory
{
private readonly DiskProvider _diskProvider;
private readonly EnvironmentProvider _environmentProvider;
2013-02-17 04:52:40 +03:00
public SiaqoDbFactory(DiskProvider diskProvider, EnvironmentProvider environmentProvider)
2013-02-17 04:52:40 +03:00
{
_diskProvider = diskProvider;
_environmentProvider = environmentProvider;
2013-02-17 04:52:40 +03:00
}
public IObjectDatabase Create(string dbPath = null)
2013-02-17 04:52:40 +03:00
{
if (string.IsNullOrWhiteSpace(dbPath))
{
dbPath = _environmentProvider.GetObjectDbFolder();
}
2013-02-17 04:52:40 +03:00
if (!_diskProvider.FolderExists(dbPath))
2013-02-17 04:52:40 +03:00
{
_diskProvider.CreateDirectory(dbPath);
}
SiaqodbConfigurator.SetTrialLicense("uvhpW4hT5Rtq+Uoyq8MOm1Smon15foxV5iS5bAegIXU=");
var db = new Siaqodb(dbPath);
return new SiaqodbProxy(db);
}
}
}