mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-19 00:39:41 +02:00
Fixed: Configured recycle bin is excluded from import.
This commit is contained in:
parent
3b191caf16
commit
e689817508
@ -8,6 +8,7 @@
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
@ -151,5 +152,107 @@ public void should_get_root_folder_with_subfolders_excluding_special_sub_folders
|
||||
unmappedFolders.Count.Should().BeGreaterThan(0);
|
||||
unmappedFolders.Should().NotContain(u => u.Name == subFolder);
|
||||
}
|
||||
|
||||
[TestCase("")]
|
||||
[TestCase(null)]
|
||||
public void should_handle_non_configured_recycle_bin(string recycleBinPath)
|
||||
{
|
||||
var rootFolder = Builder<RootFolder>.CreateNew()
|
||||
.With(r => r.Path = @"C:\Test\TV")
|
||||
.Build();
|
||||
if (OsInfo.IsNotWindows)
|
||||
{
|
||||
rootFolder = Builder<RootFolder>.CreateNew()
|
||||
.With(r => r.Path = @"/Test/TV")
|
||||
.Build();
|
||||
}
|
||||
|
||||
var subFolders = new[]
|
||||
{
|
||||
"Series1",
|
||||
"Series2",
|
||||
"Series3"
|
||||
};
|
||||
|
||||
var folders = subFolders.Select(f => Path.Combine(@"C:\Test\TV", f)).ToArray();
|
||||
|
||||
if (OsInfo.IsNotWindows)
|
||||
{
|
||||
folders = subFolders.Select(f => Path.Combine(@"/Test/TV", f)).ToArray();
|
||||
}
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.Setup(s => s.RecycleBin)
|
||||
.Returns(recycleBinPath);
|
||||
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.Get(It.IsAny<int>()))
|
||||
.Returns(rootFolder);
|
||||
|
||||
Mocker.GetMock<IMovieRepository>()
|
||||
.Setup(s => s.AllMoviePaths())
|
||||
.Returns(new Dictionary<int, string>());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetDirectories(rootFolder.Path))
|
||||
.Returns(folders);
|
||||
|
||||
var unmappedFolders = Subject.Get(rootFolder.Id, true).UnmappedFolders;
|
||||
|
||||
unmappedFolders.Count.Should().Be(3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_exclude_recycle_bin()
|
||||
{
|
||||
var rootFolder = Builder<RootFolder>.CreateNew()
|
||||
.With(r => r.Path = @"C:\Test\TV")
|
||||
.Build();
|
||||
|
||||
if (OsInfo.IsNotWindows)
|
||||
{
|
||||
rootFolder = Builder<RootFolder>.CreateNew()
|
||||
.With(r => r.Path = @"/Test/TV")
|
||||
.Build();
|
||||
}
|
||||
|
||||
var subFolders = new[]
|
||||
{
|
||||
"Series1",
|
||||
"Series2",
|
||||
"Series3",
|
||||
"BIN"
|
||||
};
|
||||
|
||||
var folders = subFolders.Select(f => Path.Combine(@"C:\Test\TV", f)).ToArray();
|
||||
|
||||
if (OsInfo.IsNotWindows)
|
||||
{
|
||||
folders = subFolders.Select(f => Path.Combine(@"/Test/TV", f)).ToArray();
|
||||
}
|
||||
|
||||
var recycleFolder = Path.Combine(OsInfo.IsNotWindows ? @"/Test/TV" : @"C:\Test\TV", "BIN");
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.Setup(s => s.RecycleBin)
|
||||
.Returns(recycleFolder);
|
||||
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.Get(It.IsAny<int>()))
|
||||
.Returns(rootFolder);
|
||||
|
||||
Mocker.GetMock<IMovieRepository>()
|
||||
.Setup(s => s.AllMoviePaths())
|
||||
.Returns(new Dictionary<int, string>());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetDirectories(rootFolder.Path))
|
||||
.Returns(folders);
|
||||
|
||||
var unmappedFolders = Subject.Get(rootFolder.Id, true).UnmappedFolders;
|
||||
|
||||
unmappedFolders.Count.Should().Be(3);
|
||||
unmappedFolders.Should().NotContain(u => u.Name == "BIN");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,12 +148,18 @@ private List<UnmappedFolder> GetUnmappedFolders(string path, Dictionary<int, str
|
||||
var possibleMovieFolders = _diskProvider.GetDirectories(path).ToList();
|
||||
var unmappedFolders = possibleMovieFolders.Except(moviePaths.Select(s => s.Value), PathEqualityComparer.Instance).ToList();
|
||||
|
||||
foreach (string unmappedFolder in unmappedFolders)
|
||||
var recycleBinPath = _configService.RecycleBin;
|
||||
|
||||
foreach (var unmappedFolder in unmappedFolders)
|
||||
{
|
||||
var di = new DirectoryInfo(unmappedFolder.Normalize());
|
||||
|
||||
if ((!di.Attributes.HasFlag(FileAttributes.System) && !di.Attributes.HasFlag(FileAttributes.Hidden)) || di.Attributes.ToString() == "-1")
|
||||
{
|
||||
results.Add(new UnmappedFolder { Name = di.Name, Path = di.FullName });
|
||||
if (string.IsNullOrWhiteSpace(recycleBinPath) || di.FullName.PathNotEquals(recycleBinPath))
|
||||
{
|
||||
results.Add(new UnmappedFolder { Name = di.Name, Path = di.FullName });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user