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 71334d1fb..c5f1a6064 100644 Binary files a/NzbDrone.Core.Test/TvTests/SeriesServiceFixture.cs and b/NzbDrone.Core.Test/TvTests/SeriesServiceFixture.cs differ diff --git a/NzbDrone.Core/Datastore/Migration/Migration20130324.cs b/NzbDrone.Core/Datastore/Migration/001_InitialSetup.cs similarity index 95% rename from NzbDrone.Core/Datastore/Migration/Migration20130324.cs rename to NzbDrone.Core/Datastore/Migration/001_InitialSetup.cs index bf9868a90..7c6b07cbd 100644 --- a/NzbDrone.Core/Datastore/Migration/Migration20130324.cs +++ b/NzbDrone.Core/Datastore/Migration/001_InitialSetup.cs @@ -4,8 +4,8 @@ using NzbDrone.Core.Datastore.Migration.Framework; namespace NzbDrone.Core.Datastore.Migration { [Tags("")] - [Migration(20130324)] - public class Migration20130324 : NzbDroneMigrationBase + [Migration(1)] + public class InitialSetup : NzbDroneMigrationBase { protected override void MainDbUpgrade() { @@ -27,8 +27,7 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Overview").AsString().Nullable() .WithColumn("AirTime").AsString().Nullable() .WithColumn("Images").AsString() - .WithColumn("RootFolderId").AsInt32() - .WithColumn("FolderName").AsString() + .WithColumn("Path").AsString() .WithColumn("Monitored").AsBoolean() .WithColumn("QualityProfileId").AsInt32() .WithColumn("SeasonFolder").AsBoolean() @@ -83,7 +82,7 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("NzbInfoUrl").AsString().Nullable() .WithColumn("ReleaseGroup").AsString().Nullable(); - Create.TableForModel("NotificationDefinitions") + Create.TableForModel("Notifications") .WithColumn("Name").AsString() .WithColumn("OnGrab").AsBoolean() .WithColumn("OnDownload").AsBoolean() @@ -95,7 +94,7 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Interval").AsInt32() .WithColumn("LastExecution").AsDateTime(); - Create.TableForModel("IndexerDefinitions") + Create.TableForModel("Indexers") .WithColumn("Enable").AsBoolean() .WithColumn("Name").AsString().Unique() .WithColumn("Implementation").AsString() diff --git a/NzbDrone.Core/Datastore/Migration/Migration20130522.cs b/NzbDrone.Core/Datastore/Migration/Migration20130522.cs deleted file mode 100644 index b356efbca..000000000 --- a/NzbDrone.Core/Datastore/Migration/Migration20130522.cs +++ /dev/null @@ -1,29 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Tags("")] - [Migration(20130522)] - public class Migration20130522 : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("DROP TABLE IF EXISTS NotificationDefinitions"); - - Rename.Table("IndexerDefinitions") - .To("Indexers"); - - Create.TableForModel("Notifications") - .WithColumn("Name").AsString() - .WithColumn("OnGrab").AsBoolean() - .WithColumn("OnDownload").AsBoolean() - .WithColumn("Settings").AsString() - .WithColumn("Implementation").AsString(); - } - - protected override void LogDbUpgrade() - { - } - } -} diff --git a/NzbDrone.Core/Datastore/TableMapping.cs b/NzbDrone.Core/Datastore/TableMapping.cs index 8e2d48ca5..4d2090ac6 100644 --- a/NzbDrone.Core/Datastore/TableMapping.cs +++ b/NzbDrone.Core/Datastore/TableMapping.cs @@ -47,9 +47,8 @@ namespace NzbDrone.Core.Datastore // .HasOne(h => 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;