diff --git a/.gitignore b/.gitignore index ac4a5fede..116ed1edb 100644 --- a/.gitignore +++ b/.gitignore @@ -133,3 +133,6 @@ NzbDrone.Web/_backboneApp/.idea/workspace.xml */.idea/workspace.xml *workspace.xml NzbDrone.Web/_backboneApp/.idea/. +*.test-cache +*.sqo +*.userprefs diff --git a/NzbDrone.Common/PathExtentions.cs b/NzbDrone.Common/PathExtentions.cs index 5eefc625a..004f39e19 100644 --- a/NzbDrone.Common/PathExtentions.cs +++ b/NzbDrone.Common/PathExtentions.cs @@ -16,10 +16,9 @@ namespace NzbDrone.Common public const string NZBDRONE_EXE = "NzbDrone.exe"; public const string NZBDRONE_SQLCE_DB_FILE = "nzbdrone.sdf"; - public const string NZBDRONE_ELQ_DB_FILE = "nzbdrone.eq"; public const string LOG_SQLCE_DB_FILE = "log.sdf"; - public const string LOG_ELQ_DB_FILE = "log.eq"; + public const string OBJ_DB_FOLDER = "objDb"; private const string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip"; @@ -96,15 +95,11 @@ namespace NzbDrone.Common return Path.Combine(environmentProvider.GetAppDataPath(), LOG_SQLCE_DB_FILE); } - public static string GetElqMainDbPath(this EnvironmentProvider environmentProvider) + public static string GetObjectDbFolder(this EnvironmentProvider environmentProvider) { - return Path.Combine(environmentProvider.GetAppDataPath(), NZBDRONE_ELQ_DB_FILE); + return Path.Combine(environmentProvider.GetAppDataPath(), OBJ_DB_FOLDER); } - public static string GetElqLogDbPath(this EnvironmentProvider environmentProvider) - { - return Path.Combine(environmentProvider.GetAppDataPath(), LOG_ELQ_DB_FILE); - } public static string GetMediaCoverPath(this EnvironmentProvider environmentProvider) { diff --git a/NzbDrone.Core.Test/Framework/ObjectDbTest.cs b/NzbDrone.Core.Test/Framework/ObjectDbTest.cs index 1d6df4375..a4787696d 100644 --- a/NzbDrone.Core.Test/Framework/ObjectDbTest.cs +++ b/NzbDrone.Core.Test/Framework/ObjectDbTest.cs @@ -52,11 +52,11 @@ namespace NzbDrone.Core.Test.Framework { if (memory) { - _db = new SiaqoDbFactory(new DiskProvider()).CreateMemoryDb(); + _db = new SiaqoDbFactory(new DiskProvider(),new EnvironmentProvider()).CreateMemoryDb(); } else { - _db = new SiaqoDbFactory(new DiskProvider()).Create(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Guid.NewGuid().ToString())); + _db = new SiaqoDbFactory(new DiskProvider(),new EnvironmentProvider()).Create(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Guid.NewGuid().ToString())); } Mocker.SetConstant(Db); diff --git a/NzbDrone.Core/ContainerExtentions.cs b/NzbDrone.Core/ContainerExtentions.cs index 51db19a76..02bf57731 100644 --- a/NzbDrone.Core/ContainerExtentions.cs +++ b/NzbDrone.Core/ContainerExtentions.cs @@ -82,7 +82,7 @@ namespace NzbDrone.Core container.Register(c => { - return c.Resolve().Create(""); + return c.Resolve().Create(); }).As().SingleInstance(); container.RegisterType().WithParameter(ResolvedParameter.ForNamed("DatabaseTarget")); diff --git a/NzbDrone.Core/Datastore/Migrations/NzbDroneMigration.cs b/NzbDrone.Core/Datastore/Migrations/NzbDroneMigration.cs index 055f46e9e..90864e9d2 100644 --- a/NzbDrone.Core/Datastore/Migrations/NzbDroneMigration.cs +++ b/NzbDrone.Core/Datastore/Migrations/NzbDroneMigration.cs @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Datastore.Migrations var sqlCeConnection = SqlCeProxy.EnsureDatabase(Database.ConnectionString); var eqPath = sqlCeConnection.Database.Replace(".sdf", ".eq"); - return new SiaqoDbFactory(new DiskProvider()).Create(eqPath); + return new SiaqoDbFactory(new DiskProvider(),new EnvironmentProvider()).Create(eqPath); } public override void Down() diff --git a/NzbDrone.Core/Datastore/ObjectDbFactory.cs b/NzbDrone.Core/Datastore/ObjectDbFactory.cs index 10a45053d..2e15389de 100644 --- a/NzbDrone.Core/Datastore/ObjectDbFactory.cs +++ b/NzbDrone.Core/Datastore/ObjectDbFactory.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using NzbDrone.Common; using Sqo; @@ -7,27 +6,28 @@ namespace NzbDrone.Core.Datastore { public interface IObjectDbFactory { - IObjectDatabase CreateMemoryDb(); - IObjectDatabase Create(string dbPath); + IObjectDatabase Create(string dbPath = null); } public class SiaqoDbFactory : IObjectDbFactory { private readonly DiskProvider _diskProvider; + private readonly EnvironmentProvider _environmentProvider; - public SiaqoDbFactory(DiskProvider diskProvider) + public SiaqoDbFactory(DiskProvider diskProvider, EnvironmentProvider environmentProvider) { _diskProvider = diskProvider; + _environmentProvider = environmentProvider; } - public IObjectDatabase CreateMemoryDb() + public IObjectDatabase Create(string dbPath = null) { - throw new NotImplementedException(); - } + if (string.IsNullOrWhiteSpace(dbPath)) + { + dbPath = _environmentProvider.GetObjectDbFolder(); + } - public IObjectDatabase Create(string dbPath) - { - if(!_diskProvider.FolderExists(dbPath)) + if (!_diskProvider.FolderExists(dbPath)) { _diskProvider.CreateDirectory(dbPath); }