From 76608fc4409d410e582f5bcdfabb61d58343bf43 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 1 Dec 2011 23:07:18 -0800 Subject: [PATCH 1/3] Banners folder moved to root. --- .gitignore | 3 ++- NzbDrone.Common/PathExtentions.cs | 12 ++++++++++- NzbDrone.Core/Datastore/Connection.cs | 27 +++++++----------------- NzbDrone.Core/Jobs/BannerDownloadJob.cs | 1 - NzbDrone.Web/Views/Series/Details.cshtml | 2 +- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index b57d38499..1b2584233 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,5 @@ _rawPackage/ NzbDrone.zip NzbDrone.sln.DotSettings.user* config.xml -UpdateLogs/ \ No newline at end of file +UpdateLogs/ +NzbDrone.Web/MediaCover \ No newline at end of file diff --git a/NzbDrone.Common/PathExtentions.cs b/NzbDrone.Common/PathExtentions.cs index 3b6d15186..04c8e70d3 100644 --- a/NzbDrone.Common/PathExtentions.cs +++ b/NzbDrone.Common/PathExtentions.cs @@ -85,9 +85,19 @@ namespace NzbDrone.Common return Path.Combine(enviromentProvider.GetAppDataPath(), LOG_DB_FILE); } + public static string GetMediaCoverPath(this EnviromentProvider enviromentProvider) + { + return Path.Combine(enviromentProvider.GetWebRoot(), "MediaCover"); + } + public static string GetBannerPath(this EnviromentProvider enviromentProvider) { - return Path.Combine(enviromentProvider.GetWebRoot(), "Content", "Images", "Banners"); + return Path.Combine(enviromentProvider.GetMediaCoverPath(), "Banner"); + } + + public static string GetFanArthPath(this EnviromentProvider enviromentProvider) + { + return Path.Combine(enviromentProvider.GetMediaCoverPath(), "Fanart"); } public static string GetCacheFolder(this EnviromentProvider enviromentProvider) diff --git a/NzbDrone.Core/Datastore/Connection.cs b/NzbDrone.Core/Datastore/Connection.cs index b41116c3e..c2a019e64 100644 --- a/NzbDrone.Core/Datastore/Connection.cs +++ b/NzbDrone.Core/Datastore/Connection.cs @@ -1,9 +1,7 @@ using System; using System.Configuration; using System.Data.Common; -using System.Data.EntityClient; using System.Data.SqlServerCe; -using MvcMiniProfiler; using NzbDrone.Common; using NzbDrone.Core.Instrumentation; using PetaPoco; @@ -14,28 +12,22 @@ namespace NzbDrone.Core.Datastore { private readonly EnviromentProvider _enviromentProvider; - - public static void InitiFacotry() + static Connection() { + Database.Mapper = new CustomeMapper(); - var dataSet = ConfigurationManager.GetSection("system.data") as System.Data.DataSet; - dataSet.Tables[0].Rows.Add("Microsoft SQL Server Compact Data Provider 4.0" - , "System.Data.SqlServerCe.4.0" - , ".NET Framework Data Provider for Microsoft SQL Server Compact" - , "System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"); + var dataSet = ConfigurationManager.GetSection("system.data") as System.Data.DataSet; + dataSet.Tables[0].Rows.Add("Microsoft SQL Server Compact Data Provider 4.0" + , "System.Data.SqlServerCe.4.0" + , ".NET Framework Data Provider for Microsoft SQL Server Compact" + , "System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"); } public Connection(EnviromentProvider enviromentProvider) { _enviromentProvider = enviromentProvider; } - - static Connection() - { - Database.Mapper = new CustomeMapper(); - InitiFacotry(); - } - + public String MainConnectionString { get @@ -54,7 +46,6 @@ namespace NzbDrone.Core.Datastore public static string GetConnectionString(string path) { - //return String.Format("Data Source={0};Version=3;Cache Size=30000;Pooling=true;Default Timeout=2", path); return String.Format("Data Source={0}", path); } @@ -73,8 +64,6 @@ namespace NzbDrone.Core.Datastore return GetLogDbContext(LogConnectionString); } - - public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true) { MigrationsHelper.Run(connectionString, true); diff --git a/NzbDrone.Core/Jobs/BannerDownloadJob.cs b/NzbDrone.Core/Jobs/BannerDownloadJob.cs index 255ddf26e..38edbf5bc 100644 --- a/NzbDrone.Core/Jobs/BannerDownloadJob.cs +++ b/NzbDrone.Core/Jobs/BannerDownloadJob.cs @@ -7,7 +7,6 @@ using NzbDrone.Common; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Core; -using NzbDrone.Core.Providers.Jobs; using NzbDrone.Core.Repository; namespace NzbDrone.Core.Jobs diff --git a/NzbDrone.Web/Views/Series/Details.cshtml b/NzbDrone.Web/Views/Series/Details.cshtml index 2d88ea812..dda81408b 100644 --- a/NzbDrone.Web/Views/Series/Details.cshtml +++ b/NzbDrone.Web/Views/Series/Details.cshtml @@ -78,7 +78,7 @@ if(Model.HasBanner) { - bannerUrl = "../../Content/Images/Banners/" + Model.SeriesId + ".jpg"; + bannerUrl = "../../MediaCover/Banner/" + Model.SeriesId + ".jpg"; } } Banner From 08a5b28f4090e8f21a5a1a19bff4d3d929611fa2 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 1 Dec 2011 23:20:33 -0800 Subject: [PATCH 2/3] Banners folder moved to root. --- NzbDrone.Common/PathExtentions.cs | 4 ++-- NzbDrone.Web/Views/Series/Details.cshtml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NzbDrone.Common/PathExtentions.cs b/NzbDrone.Common/PathExtentions.cs index 04c8e70d3..16fb16db6 100644 --- a/NzbDrone.Common/PathExtentions.cs +++ b/NzbDrone.Common/PathExtentions.cs @@ -92,12 +92,12 @@ namespace NzbDrone.Common public static string GetBannerPath(this EnviromentProvider enviromentProvider) { - return Path.Combine(enviromentProvider.GetMediaCoverPath(), "Banner"); + return Path.Combine(enviromentProvider.GetMediaCoverPath(), "Banners"); } public static string GetFanArthPath(this EnviromentProvider enviromentProvider) { - return Path.Combine(enviromentProvider.GetMediaCoverPath(), "Fanart"); + return Path.Combine(enviromentProvider.GetMediaCoverPath(), "Fanarts"); } public static string GetCacheFolder(this EnviromentProvider enviromentProvider) diff --git a/NzbDrone.Web/Views/Series/Details.cshtml b/NzbDrone.Web/Views/Series/Details.cshtml index dda81408b..22a57044e 100644 --- a/NzbDrone.Web/Views/Series/Details.cshtml +++ b/NzbDrone.Web/Views/Series/Details.cshtml @@ -78,7 +78,7 @@ if(Model.HasBanner) { - bannerUrl = "../../MediaCover/Banner/" + Model.SeriesId + ".jpg"; + bannerUrl = "../../MediaCover/Banners/" + Model.SeriesId + ".jpg"; } } Banner From ce8713d953f1f1b648d760166a6fbaaa559f3ec1 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 1 Dec 2011 23:26:38 -0800 Subject: [PATCH 3/3] last fix for deleted job didn't work, this should fix it. --- .../JobProviderTests/JobProviderFixture.cs | 27 ++++++++++++++++--- NzbDrone.Core/Jobs/JobProvider.cs | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs index c132925e2..5017fffb3 100644 --- a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs @@ -290,20 +290,41 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests { IList fakeJobs = new List { fakeJob }; Mocker.SetConstant(fakeJobs); - + WithRealDb(); var deletedJob = Builder.CreateNew().Build(); Db.Insert(deletedJob); var jobProvider = Mocker.Resolve(); - + //Act jobProvider.Initialize(); //Assert var registeredJobs = Db.Fetch(); registeredJobs.Should().HaveCount(1); - registeredJobs.Should().NotContain(c => c.Name == deletedJob.Name); + registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName); + } + [Test] + public void inti_should_removed_jobs_that_no_longer_exist_even_with_same_name() + { + IList fakeJobs = new List { fakeJob }; + Mocker.SetConstant(fakeJobs); + + WithRealDb(); + var deletedJob = Builder.CreateNew() + .With(c => c.Name = fakeJob.Name).Build(); + + Db.Insert(deletedJob); + var jobProvider = Mocker.Resolve(); + + //Act + jobProvider.Initialize(); + + //Assert + var registeredJobs = Db.Fetch(); + registeredJobs.Should().HaveCount(1); + registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName); } [Test] diff --git a/NzbDrone.Core/Jobs/JobProvider.cs b/NzbDrone.Core/Jobs/JobProvider.cs index f63fc997c..4a8e28e0b 100644 --- a/NzbDrone.Core/Jobs/JobProvider.cs +++ b/NzbDrone.Core/Jobs/JobProvider.cs @@ -76,7 +76,7 @@ namespace NzbDrone.Core.Jobs foreach (var currentJob in currentJobs) { - if (!_jobs.Any(c => c.Name == currentJob.Name)) + if (!_jobs.Any(c => c.GetType().ToString() == currentJob.TypeName)) { logger.Debug("Removing job from database '{0}'", currentJob.Name); _database.Delete(currentJob);