From 6072a58c57fbb80cb96839fa9357a97d3dc070bc Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 26 Mar 2014 07:28:40 -0700 Subject: [PATCH] Fixed: Ignore Apple generated files when adding existing series --- .../RootFolderServiceFixture.cs | 25 +++++++++++++++---- .../RootFolders/RootFolderService.cs | 11 +++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs b/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs index f63b60cd5..624749dc3 100644 --- a/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs +++ b/src/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs @@ -4,10 +4,10 @@ using System.IO; using FluentAssertions; using Moq; using NUnit.Framework; -using NzbDrone.Common; using NzbDrone.Common.Disk; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Tv; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.RootFolderTests @@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.RootFolderTests .Returns(new List()); } - private void WithNoneExistingFolder() + private void WithNonExistingFolder() { Mocker.GetMock() .Setup(m => m.FolderExists(It.IsAny())) @@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.RootFolderTests [Test] public void should_throw_if_folder_being_added_doesnt_exist() { - WithNoneExistingFolder(); + WithNonExistingFolder(); Assert.Throws(() => Subject.Add(new RootFolder { Path = "C:\\TEST".AsOsAgnostic() })); } @@ -62,9 +62,9 @@ namespace NzbDrone.Core.Test.RootFolderTests } [Test] - public void None_existing_folder_returns_empty_list() + public void should_return_empty_list_when_folder_doesnt_exist() { - WithNoneExistingFolder(); + WithNonExistingFolder(); Mocker.GetMock().Setup(c => c.All()).Returns(new List()); @@ -100,5 +100,20 @@ namespace NzbDrone.Core.Test.RootFolderTests Assert.Throws(() => Subject.Add(new RootFolder { Path = @"C:\TV".AsOsAgnostic() })); } + + [Test] + public void should_not_include_system_files_and_folders() + { + Mocker.GetMock() + .Setup(s => s.GetDirectories(It.IsAny())) + .Returns(new string[] {@"C:\30 Rock", @"C:\$Recycle.Bin", @"C:\.AppleDouble"}); + + Mocker.GetMock() + .Setup(s => s.GetAllSeries()) + .Returns(new List()); + + Subject.GetUnmappedFolders(@"C:\") + .Should().OnlyContain(u => u.Path == @"C:\30 Rock"); + } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/RootFolders/RootFolderService.cs b/src/NzbDrone.Core/RootFolders/RootFolderService.cs index ea5285327..7d47c01b4 100644 --- a/src/NzbDrone.Core/RootFolders/RootFolderService.cs +++ b/src/NzbDrone.Core/RootFolders/RootFolderService.cs @@ -31,7 +31,16 @@ namespace NzbDrone.Core.RootFolders private readonly IConfigService _configService; private readonly Logger _logger; - private static readonly HashSet SpecialFolders = new HashSet { "$recycle.bin", "system volume information", "recycler", "lost+found" }; + private static readonly HashSet SpecialFolders = new HashSet + { + "$recycle.bin", + "system volume information", + "recycler", + "lost+found", + ".appledb", + ".appledesktop", + ".appledouble" + }; public RootFolderService(IRootFolderRepository rootFolderRepository,