diff --git a/NzbDrone.Api/Series/SeriesModule.cs b/NzbDrone.Api/Series/SeriesModule.cs index 8057fe368..58ec784e9 100644 --- a/NzbDrone.Api/Series/SeriesModule.cs +++ b/NzbDrone.Api/Series/SeriesModule.cs @@ -75,9 +75,10 @@ private Response UpdateSeries() series.SeasonFolder = request.SeasonFolder; series.QualityProfileId = request.QualityProfileId; - var oldPath = series.Path; + //Todo: Do we want to force a scan when this path changes? Can we use events instead? + series.RootFolderId = request.RootFolderId; + series.FolderName = request.FolderName; - series.Path = request.Path; series.BacklogSetting = (BacklogSettingType)request.BacklogSetting; if (!String.IsNullOrWhiteSpace(request.CustomStartDate)) @@ -88,11 +89,6 @@ private Response UpdateSeries() _seriesRepository.Update(series); - if (oldPath != series.Path) - _jobProvider.Enqueue(typeof(DiskScanJob), new { SeriesId = series.Id }); - - _seriesRepository.Update(series); - return request.AsResponse(); } diff --git a/NzbDrone.Api/Series/SeriesResource.cs b/NzbDrone.Api/Series/SeriesResource.cs index b2347bb34..a83b0e8b6 100644 --- a/NzbDrone.Api/Series/SeriesResource.cs +++ b/NzbDrone.Api/Series/SeriesResource.cs @@ -37,7 +37,8 @@ public class SeriesResource public List Images { get; set; } //View & Edit - public String Path { get; set; } + public int RootFolderId { get; set; } + public string FolderName { get; set; } public Int32 QualityProfileId { get; set; } //Editing Only diff --git a/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs b/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs index 142a886a7..a1ff8d200 100644 --- a/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs +++ b/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs @@ -1,10 +1,12 @@ using System.Linq; using FizzWare.NBuilder; using FluentAssertions; +using Marr.Data; using NUnit.Framework; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Organizer; +using NzbDrone.Core.RootFolders; using NzbDrone.Core.Tv; using NzbDrone.Core.Test.Framework; @@ -31,7 +33,8 @@ public void CalculateFilePath_SeasonFolder_SingleNumber(string filename, int sea { var fakeSeries = Builder.CreateNew() .With(s => s.Title = "30 Rock") - .With(s => s.Path = @"C:\Test\30 Rock") + .With(s => s.RootFolder = new LazyLoaded(new RootFolder { Path = @"C:\Test\TV" })) + .With(s => s.FolderName = "30 Rock") .With(s => s.SeasonFolder = useSeasonFolder) .Build(); diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs index 2da99d67d..d360d029f 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs @@ -5,10 +5,12 @@ using System.Linq; using FizzWare.NBuilder; +using Marr.Data; using Moq; using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.RootFolders; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; @@ -28,7 +30,8 @@ public class ProcessDownloadFixture : CoreTest public void Setup() { fakeSeries = Builder.CreateNew() - .With(s => s.Path = @"C:\Test\TV\30 Rock") + .With(s => s.RootFolder = new LazyLoaded(new RootFolder { Path = @"C:\Test\TV" })) + .With(s => s.FolderName = "30 Rock") .Build(); } @@ -342,7 +345,8 @@ public void should_logError_and_return_if_size_exceeds_free_space() var series = Builder.CreateNew() .With(s => s.Title = "30 Rock") - .With(s => s.Path = @"C:\Test\TV\30 Rock") + .With(s => s.RootFolder = new LazyLoaded(new RootFolder { Path = @"C:\Test\TV" })) + .With(s => s.FolderName = "30 Rock") .Build(); Mocker.GetMock() diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs index 5be2e75c6..84c65efec 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs @@ -5,10 +5,12 @@ using System.Linq; using FizzWare.NBuilder; +using Marr.Data; using Moq; using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.RootFolders; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; @@ -28,7 +30,8 @@ public class ProcessDropDirectoryFixture : CoreTest public void Setup() { fakeSeries = Builder.CreateNew() - .With(s => s.Path = @"C:\Test\TV\30 Rock") + .With(s => s.RootFolder = new LazyLoaded(new RootFolder { Path = @"C:\Test\TV" })) + .With(s => s.FolderName = "30 Rock") .Build(); } diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs index 78741b11b..10d9e5e96 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs @@ -5,10 +5,12 @@ using System.Linq; using FizzWare.NBuilder; +using Marr.Data; using Moq; using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.RootFolders; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; @@ -28,7 +30,8 @@ public class ProcessVideoFileFixture : CoreTest public void Setup() { fakeSeries = Builder.CreateNew() - .With(s => s.Path = @"C:\Test\TV\30 Rock") + .With(s => s.RootFolder = new LazyLoaded(new RootFolder { Path = @"C:\Test\TV" })) + .With(s => s.FolderName = "30 Rock") .Build(); } @@ -147,7 +150,8 @@ public void should_logError_and_return_if_size_exceeds_free_space() var series = Builder.CreateNew() .With(s => s.Title = "30 Rock") - .With(s => s.Path = @"C:\Test\TV\30 Rock") + .With(s => s.RootFolder = new LazyLoaded(new RootFolder { Path = @"C:\Test\TV" })) + .With(s => s.FolderName = "30 Rock") .Build(); Mocker.GetMock() diff --git a/NzbDrone.Core/Datastore/Migration/Migration20130324.cs b/NzbDrone.Core/Datastore/Migration/Migration20130324.cs index fe035ac91..4dc03f3a8 100644 --- a/NzbDrone.Core/Datastore/Migration/Migration20130324.cs +++ b/NzbDrone.Core/Datastore/Migration/Migration20130324.cs @@ -28,7 +28,7 @@ protected override void MainDbUpgrade() .WithColumn("AirTime").AsString().Nullable() .WithColumn("Images").AsString() .WithColumn("RootFolderId").AsInt32() - .WithColumn("Folder").AsString().NotNullable() + .WithColumn("FolderName").AsString() .WithColumn("Monitored").AsBoolean() .WithColumn("QualityProfileId").AsInt32() .WithColumn("SeasonFolder").AsBoolean() diff --git a/NzbDrone.Core/Tv/Series.cs b/NzbDrone.Core/Tv/Series.cs index 3f1044676..01e30bf0e 100644 --- a/NzbDrone.Core/Tv/Series.cs +++ b/NzbDrone.Core/Tv/Series.cs @@ -47,13 +47,13 @@ public Series() public string TitleSlug { get; set; } public int RootFolderId { get; set; } - public string Folder { 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 { return System.IO.Path.Combine(RootFolder.Value.Path, Folder); } + get { return System.IO.Path.Combine(RootFolder.Value.Path, FolderName); } } //Todo: This should be a double since there are timezones that aren't on a full hour offset diff --git a/NzbDrone.Core/Tv/SeriesService.cs b/NzbDrone.Core/Tv/SeriesService.cs index 66f93b9a1..d66438f8b 100644 --- a/NzbDrone.Core/Tv/SeriesService.cs +++ b/NzbDrone.Core/Tv/SeriesService.cs @@ -91,10 +91,10 @@ public void AddSeries(Series newSeries) { Ensure.That(() => newSeries).IsNotNull(); - if(String.IsNullOrWhiteSpace(newSeries.Folder)) + if(String.IsNullOrWhiteSpace(newSeries.FolderName)) { - newSeries.Folder = FileNameBuilder.CleanFilename(newSeries.Title); - _diskProvider.CreateDirectory(Path.Combine(_rootFolderRepository.Get(newSeries.RootFolderId).Path, newSeries.Folder)); + newSeries.FolderName = FileNameBuilder.CleanFilename(newSeries.Title); + _diskProvider.CreateDirectory(Path.Combine(_rootFolderRepository.Get(newSeries.RootFolderId).Path, newSeries.FolderName)); } _logger.Info("Adding Series [{0}] Path: [{1}]", newSeries.Title, newSeries.Path); @@ -123,7 +123,7 @@ public void UpdateFromSeriesEditor(IList editedSeries) series.Monitored = edited.Monitored; series.SeasonFolder = edited.SeasonFolder; series.BacklogSetting = edited.BacklogSetting; - series.Path = edited.Path; + //series.Path = edited.Path; series.CustomStartDate = edited.CustomStartDate; _seriesRepository.Update(series);