From 95a9a297bc976f6a70e2d06747dae0cad45fee3f Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 23 May 2013 21:10:56 -0700 Subject: [PATCH] RootFolder removed from Series, going back to Path --- NzbDrone.Api/Series/SeriesModule.cs | 1 - NzbDrone.Api/Series/SeriesResource.cs | 9 ++---- .../Datastore/ObjectDatabaseFixture.cs | 19 ------------ .../MediaFileTests/MediaFileServiceTest.cs | 3 +- .../TvTests/SeriesServiceFixture.cs | Bin 2375 -> 2253 bytes ...gration20130324.cs => 001_InitialSetup.cs} | 11 +++---- .../Datastore/Migration/Migration20130522.cs | 29 ------------------ NzbDrone.Core/Datastore/TableMapping.cs | 3 +- NzbDrone.Core/NzbDrone.Core.csproj | 3 +- NzbDrone.Core/Tv/Series.cs | 19 ++---------- NzbDrone.Core/Tv/SeriesService.cs | 7 +++-- .../SeriesIntegrationTest.cs | 5 +-- UI/AddSeries/Existing/ImportSeriesView.js | 6 ++-- UI/AddSeries/New/SearchResultView.js | 4 +-- 14 files changed, 21 insertions(+), 98 deletions(-) rename NzbDrone.Core/Datastore/Migration/{Migration20130324.cs => 001_InitialSetup.cs} (95%) delete mode 100644 NzbDrone.Core/Datastore/Migration/Migration20130522.cs diff --git a/NzbDrone.Api/Series/SeriesModule.cs b/NzbDrone.Api/Series/SeriesModule.cs index be648aad0..3b2291863 100644 --- a/NzbDrone.Api/Series/SeriesModule.cs +++ b/NzbDrone.Api/Series/SeriesModule.cs @@ -29,7 +29,6 @@ namespace NzbDrone.Api.Series Get["/{slug}"] = o => GetSeries((string)o.slug.ToString()); - SharedValidator.RuleFor(s => s.RootFolderId).ValidId(); SharedValidator.RuleFor(s => s.QualityProfileId).ValidId(); PostValidator.RuleFor(s => s.Title).NotEmpty(); diff --git a/NzbDrone.Api/Series/SeriesResource.cs b/NzbDrone.Api/Series/SeriesResource.cs index e6361d493..a5f71a7d5 100644 --- a/NzbDrone.Api/Series/SeriesResource.cs +++ b/NzbDrone.Api/Series/SeriesResource.cs @@ -26,11 +26,8 @@ namespace NzbDrone.Api.Series public Int32 UtcOffset { get; set; } public List Images { get; set; } - public String Path { get; set; } - //View & Edit - public int RootFolderId { get; set; } - public string FolderName { get; set; } + public String Path { get; set; } public Int32 QualityProfileId { get; set; } //Editing Only @@ -50,8 +47,6 @@ namespace NzbDrone.Api.Series public String CleanTitle { get; set; } public String ImdbId { get; set; } public String TitleSlug { get; set; } - - - + public String RootFolderPath { get; set; } } } diff --git a/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs b/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs index 9abb24a99..353ed5629 100644 --- a/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs +++ b/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs @@ -144,25 +144,6 @@ namespace NzbDrone.Core.Test.Datastore Db.All().Single().TypeName.Should().Be("A"); Db.All().Single().Interval.Should().Be(12); } - - [Test] - public void should_load_lazy_objects() - { - - var rootFolder = Db.Insert(new RootFolders.RootFolder() { Path = "C:\test" }); - - var series = Builder.CreateNew() - .With(c => c.RootFolderId = rootFolder.Id) - .BuildNew(); - - Db.Insert(series); - - - Db.Single().RootFolder.Should().NotBeNull(); - Db.Single().RootFolder.Value.Should().NotBeNull(); - Db.Single().RootFolder.Value.Path.Should().Be(rootFolder.Path); - - } } } diff --git a/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs b/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs index 1517a3151..f626159e8 100644 --- a/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs +++ b/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs @@ -33,8 +33,7 @@ namespace NzbDrone.Core.Test.MediaFileTests { var fakeSeries = Builder.CreateNew() .With(s => s.Title = "30 Rock") - .With(s => s.RootFolder = new LazyLoaded(new RootFolder { Path = @"C:\Test" })) - .With(s => s.FolderName = "30 Rock") + .With(s => s.Path = @"C:\Test\30 Rock") .With(s => s.SeasonFolder = useSeasonFolder) .Build(); diff --git a/NzbDrone.Core.Test/TvTests/SeriesServiceFixture.cs b/NzbDrone.Core.Test/TvTests/SeriesServiceFixture.cs index 71334d1fb35459cd46b3645dba28b4cd11d24524..c5f1a6064fac4fe3d5842bb587a7ad7fe60d0912 100644 GIT binary patch delta 73 zcmX>ubXIVK81rO(R&Jhv#F7jJTZO#RoE+=PimZ}yLHYS5ZuvPWsYOsJ2PJ2#n2^-s Vl9-S%rO9)dgIPcln@w4SSOH2r7Ipvt delta 198 zcmX>rcwA_M7_+NyesXqdk)C^M35aFm8I+%2;+CJ2l3Em;T2z*qoNA|`sTZ7DQd*#q ztYB-WkPK3);aQ^RS?risX_J{(0#q=$hDBC2FST3&p h.Series, h => h.SeriesId); Mapper.Entity().RegisterModel("Series") - .Ignore(s => s.Path) + .Ignore(s => s.RootFolderPath) .Relationship() - .HasOne(s => s.RootFolder, s => s.RootFolderId) .HasOne(s => s.QualityProfile, s => s.QualityProfileId); Mapper.Entity().RegisterModel("Seasons"); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 72038b0c8..f0c08a2ed 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -202,12 +202,11 @@ - - + diff --git a/NzbDrone.Core/Tv/Series.cs b/NzbDrone.Core/Tv/Series.cs index 54887e409..c56fdd9b2 100644 --- a/NzbDrone.Core/Tv/Series.cs +++ b/NzbDrone.Core/Tv/Series.cs @@ -36,24 +36,9 @@ namespace NzbDrone.Core.Tv public DateTime? CustomStartDate { get; set; } public bool UseSceneNumbering { get; set; } public string TitleSlug { get; set; } + public string Path { get; set; } - public int RootFolderId { get; set; } - public string FolderName { get; set; } - public LazyLoaded RootFolder { get; set; } - - //Todo: Use this to auto link RootFolder and Folder (using the proper path separator) - public string Path - { - get - { - if (RootFolder == null || RootFolder.Value == null || String.IsNullOrWhiteSpace(RootFolder.Value.Path)) - { - return null; - } - - return System.IO.Path.Combine(RootFolder.Value.Path, FolderName); - } - } + public string RootFolderPath { get; set; } public DateTime? FirstAired { get; set; } public LazyLoaded QualityProfile { get; set; } diff --git a/NzbDrone.Core/Tv/SeriesService.cs b/NzbDrone.Core/Tv/SeriesService.cs index 8bc8c214b..05b56cccf 100644 --- a/NzbDrone.Core/Tv/SeriesService.cs +++ b/NzbDrone.Core/Tv/SeriesService.cs @@ -101,10 +101,11 @@ namespace NzbDrone.Core.Tv { Ensure.That(() => newSeries).IsNotNull(); - if (String.IsNullOrWhiteSpace(newSeries.FolderName)) + if (String.IsNullOrWhiteSpace(newSeries.Path)) { - newSeries.FolderName = FileNameBuilder.CleanFilename(newSeries.Title); - newSeries.RootFolder = _rootFolderService.Get(newSeries.RootFolderId); + var folderName = FileNameBuilder.CleanFilename(newSeries.Title); + newSeries.Path = Path.Combine(newSeries.RootFolderPath, folderName); + _diskProvider.CreateFolder(newSeries.Path); } diff --git a/NzbDrone.Integration.Test/SeriesIntegrationTest.cs b/NzbDrone.Integration.Test/SeriesIntegrationTest.cs index 6d38d9231..7be3233c7 100644 --- a/NzbDrone.Integration.Test/SeriesIntegrationTest.cs +++ b/NzbDrone.Integration.Test/SeriesIntegrationTest.cs @@ -38,16 +38,13 @@ namespace NzbDrone.Integration.Test { var series = Series.Lookup("archer").First(); - var rootFolder = RootFolders.Post(new RootFolderResource { Path = Directory.GetCurrentDirectory() }); - - series.RootFolderId = rootFolder.Id; series.QualityProfileId = 1; + series.Path = @"C:\Test\Archer"; series = Series.Post(series); Series.All().Should().HaveCount(1); - Series.Get(series.Id).Should().NotBeNull(); Series.Get(series.TitleSlug).Should().NotBeNull(); diff --git a/UI/AddSeries/Existing/ImportSeriesView.js b/UI/AddSeries/Existing/ImportSeriesView.js index 0816ec5a7..108cfc978 100644 --- a/UI/AddSeries/Existing/ImportSeriesView.js +++ b/UI/AddSeries/Existing/ImportSeriesView.js @@ -29,12 +29,10 @@ define([ var self = this; var quality = this.ui.qualityProfile.val(); - var rootFolderId = this.options.rootFolder.id; - var folderName = this.options.folder.name; + var path = this.options.folder.path; this.model.set('qualityProfileId', quality); - this.model.set('rootFolderId', rootFolderId); - this.model.set('folderName', folderName); + this.model.set('path', path); this.model.save(undefined, { success: function () { diff --git a/UI/AddSeries/New/SearchResultView.js b/UI/AddSeries/New/SearchResultView.js index b48b3778c..e635f68de 100644 --- a/UI/AddSeries/New/SearchResultView.js +++ b/UI/AddSeries/New/SearchResultView.js @@ -24,10 +24,10 @@ define(['app', 'Series/SeriesCollection'], function (app) { icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled'); var quality = this.ui.qualityProfile.val(); - var rootFolderId = this.ui.rootFolder.val(); + var rootFolderPath = this.ui.rootFolder.children(':selected').text(); this.model.set('qualityProfileId', quality); - this.model.set('rootFolderId', rootFolderId); + this.model.set('rootFolderPath', rootFolderPath); var self = this;