Fixed: Ignore Apple generated files when adding existing series

This commit is contained in:
Mark McDowall 2014-03-26 07:28:40 -07:00
parent f88a83ae10
commit 6072a58c57
2 changed files with 30 additions and 6 deletions

View File

@ -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<RootFolder>());
}
private void WithNoneExistingFolder()
private void WithNonExistingFolder()
{
Mocker.GetMock<IDiskProvider>()
.Setup(m => m.FolderExists(It.IsAny<string>()))
@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.RootFolderTests
[Test]
public void should_throw_if_folder_being_added_doesnt_exist()
{
WithNoneExistingFolder();
WithNonExistingFolder();
Assert.Throws<DirectoryNotFoundException>(() => 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<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() }));
}
[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");
}
}
}

View File

@ -31,7 +31,16 @@ namespace NzbDrone.Core.RootFolders
private readonly IConfigService _configService;
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,