From bb5febaadec1d380c8aad1b58073c02fdcbcb965 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 22 Oct 2011 12:03:54 -0700 Subject: [PATCH] DiskScanProvider.Scan() will log a warning if the path doesn't exist. --- .../ProviderTests/DiskScanProviderTest.cs | 30 +++++++++++++++++-- NzbDrone.Core/Providers/DiskScanProvider.cs | 6 ++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs index c00f22c39..5c90daa12 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs @@ -14,7 +14,6 @@ namespace NzbDrone.Core.Test.ProviderTests // ReSharper disable InconsistentNaming public class DiskScanProviderTest : TestBase { - [Test] public void scan_series_should_update_last_scan_date() { @@ -38,7 +37,6 @@ public void scan_series_should_update_last_scan_date() } - [Test] public void cleanup_should_skip_existing_files() { @@ -89,7 +87,6 @@ public void cleanup_should_delete_none_existing_files() } - [Test] public void cleanup_should_delete_none_existing_files_remove_links_to_episodes() { @@ -131,7 +128,34 @@ public void cleanup_should_delete_none_existing_files_remove_links_to_episodes() } + [Test] + public void scan_series_should_log_warning_if_path_doesnt_exist_on_disk() + { + //Setup + var mocker = new AutoMoqer(MockBehavior.Strict); + var series = Builder.CreateNew() + .With(s => s.Path = @"C:\Test\TV\SeriesName\") + .Build(); + mocker.GetMock() + .Setup(c => c.DeleteOrphaned()) + .Returns(0); + + mocker.GetMock() + .Setup(c => c.RepairLinks()) + .Returns(0); + + mocker.GetMock() + .Setup(c => c.FolderExists(series.Path)) + .Returns(false); + + //Act + mocker.Resolve().Scan(series, series.Path); + + //Assert + mocker.VerifyAllMocks(); + ExceptionVerification.ExcpectedWarns(1); + } } } diff --git a/NzbDrone.Core/Providers/DiskScanProvider.cs b/NzbDrone.Core/Providers/DiskScanProvider.cs index 070d2ad9a..441fa747a 100644 --- a/NzbDrone.Core/Providers/DiskScanProvider.cs +++ b/NzbDrone.Core/Providers/DiskScanProvider.cs @@ -58,6 +58,12 @@ public virtual List Scan(Series series, string path) _mediaFileProvider.DeleteOrphaned(); _mediaFileProvider.RepairLinks(); + if (!_diskProvider.FolderExists(path)) + { + Logger. Warn("Series folder doesn't exist: {0}", path); + return new List(); + } + if (_episodeProvider.GetEpisodeBySeries(series.SeriesId).Count == 0) { Logger.Debug("Series {0} has no episodes. skipping", series.Title);