Fixed: Ignore Apple generated files when adding existing series

pull/2/head
Mark McDowall 11 years ago
parent f88a83ae10
commit 6072a58c57

@ -4,10 +4,10 @@ using System.IO;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Core.RootFolders; using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.RootFolderTests namespace NzbDrone.Core.Test.RootFolderTests
@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.RootFolderTests
.Returns(new List<RootFolder>()); .Returns(new List<RootFolder>());
} }
private void WithNoneExistingFolder() private void WithNonExistingFolder()
{ {
Mocker.GetMock<IDiskProvider>() Mocker.GetMock<IDiskProvider>()
.Setup(m => m.FolderExists(It.IsAny<string>())) .Setup(m => m.FolderExists(It.IsAny<string>()))
@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.RootFolderTests
[Test] [Test]
public void should_throw_if_folder_being_added_doesnt_exist() public void should_throw_if_folder_being_added_doesnt_exist()
{ {
WithNoneExistingFolder(); WithNonExistingFolder();
Assert.Throws<DirectoryNotFoundException>(() => Subject.Add(new RootFolder { Path = "C:\\TEST".AsOsAgnostic() })); Assert.Throws<DirectoryNotFoundException>(() => Subject.Add(new RootFolder { Path = "C:\\TEST".AsOsAgnostic() }));
} }
@ -62,9 +62,9 @@ namespace NzbDrone.Core.Test.RootFolderTests
} }
[Test] [Test]
public void None_existing_folder_returns_empty_list() public void should_return_empty_list_when_folder_doesnt_exist()
{ {
WithNoneExistingFolder(); WithNonExistingFolder();
Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootFolder>()); Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootFolder>());
@ -100,5 +100,20 @@ namespace NzbDrone.Core.Test.RootFolderTests
Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootFolder { Path = @"C:\TV".AsOsAgnostic() })); Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootFolder { Path = @"C:\TV".AsOsAgnostic() }));
} }
[Test]
public void should_not_include_system_files_and_folders()
{
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetDirectories(It.IsAny<String>()))
.Returns(new string[] {@"C:\30 Rock", @"C:\$Recycle.Bin", @"C:\.AppleDouble"});
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetAllSeries())
.Returns(new List<Series>());
Subject.GetUnmappedFolders(@"C:\")
.Should().OnlyContain(u => u.Path == @"C:\30 Rock");
}
} }
} }

@ -31,7 +31,16 @@ namespace NzbDrone.Core.RootFolders
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly Logger _logger; private readonly Logger _logger;
private static readonly HashSet<string> SpecialFolders = new HashSet<string> { "$recycle.bin", "system volume information", "recycler", "lost+found" }; private static readonly HashSet<string> SpecialFolders = new HashSet<string>
{
"$recycle.bin",
"system volume information",
"recycler",
"lost+found",
".appledb",
".appledesktop",
".appledouble"
};
public RootFolderService(IRootFolderRepository rootFolderRepository, public RootFolderService(IRootFolderRepository rootFolderRepository,

Loading…
Cancel
Save