2013-02-17 07:59:35 +03:00
|
|
|
using System.Linq;
|
2013-02-17 04:52:40 +03:00
|
|
|
using NzbDrone.Common;
|
|
|
|
using Sqo;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Datastore
|
|
|
|
{
|
|
|
|
public interface IObjectDbFactory
|
|
|
|
{
|
2013-02-17 07:59:35 +03:00
|
|
|
IObjectDatabase Create(string dbPath = null);
|
2013-02-17 04:52:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public class SiaqoDbFactory : IObjectDbFactory
|
|
|
|
{
|
|
|
|
private readonly DiskProvider _diskProvider;
|
2013-02-17 07:59:35 +03:00
|
|
|
private readonly EnvironmentProvider _environmentProvider;
|
2013-02-17 04:52:40 +03:00
|
|
|
|
2013-02-17 07:59:35 +03:00
|
|
|
public SiaqoDbFactory(DiskProvider diskProvider, EnvironmentProvider environmentProvider)
|
2013-02-17 04:52:40 +03:00
|
|
|
{
|
|
|
|
_diskProvider = diskProvider;
|
2013-02-17 07:59:35 +03:00
|
|
|
_environmentProvider = environmentProvider;
|
2013-02-17 04:52:40 +03:00
|
|
|
}
|
|
|
|
|
2013-02-17 07:59:35 +03:00
|
|
|
public IObjectDatabase Create(string dbPath = null)
|
2013-02-17 04:52:40 +03:00
|
|
|
{
|
2013-02-17 07:59:35 +03:00
|
|
|
if (string.IsNullOrWhiteSpace(dbPath))
|
|
|
|
{
|
|
|
|
dbPath = _environmentProvider.GetObjectDbFolder();
|
|
|
|
}
|
2013-02-17 04:52:40 +03:00
|
|
|
|
2013-02-17 07:59:35 +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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|