1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-25 22:37:27 -04:00

New: Use Movie Folder Format to improve unmapped folders within root folders

(cherry picked from commit 81d2b18ce1c079c2a9dc3de037c9dceea16733fd)

Closes #8065
This commit is contained in:
Mark McDowall
2023-02-04 15:18:32 -08:00
committed by Bogdan
parent 7198aa24a6
commit c9da7ee0c9
8 changed files with 81 additions and 6 deletions
@@ -10,6 +10,7 @@ using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
@@ -19,9 +20,13 @@ namespace NzbDrone.Core.Test.RootFolderTests
[TestFixture]
public class RootFolderServiceFixture : CoreTest<RootFolderService>
{
private NamingConfig _namingConfig;
[SetUp]
public void Setup()
{
_namingConfig = NamingConfig.Default;
Mocker.GetMock<IDiskProvider>()
.Setup(m => m.FolderExists(It.IsAny<string>()))
.Returns(true);
@@ -33,6 +38,10 @@ namespace NzbDrone.Core.Test.RootFolderTests
Mocker.GetMock<IRootFolderRepository>()
.Setup(s => s.All())
.Returns(new List<RootFolder>());
Mocker.GetMock<INamingConfigService>()
.Setup(c => c.GetConfig())
.Returns(_namingConfig);
}
private void WithNonExistingFolder()
@@ -254,5 +263,47 @@ namespace NzbDrone.Core.Test.RootFolderTests
unmappedFolders.Count.Should().Be(3);
unmappedFolders.Should().NotContain(u => u.Name == "BIN");
}
[Test]
public void should_get_unmapped_folders_inside_letter_subfolder()
{
_namingConfig.MovieFolderFormat = "{Movie TitleFirstCharacter}\\{Movie Title}".AsOsAgnostic();
var rootFolderPath = @"C:\Test\Movies".AsOsAgnostic();
var rootFolder = Builder<RootFolder>.CreateNew()
.With(r => r.Path = rootFolderPath)
.Build();
var subFolderPath = Path.Combine(rootFolderPath, "M");
var subFolders = new[]
{
"Movie1",
"Movie2",
"Movie3",
};
var folders = subFolders.Select(f => Path.Combine(subFolderPath, f)).ToArray();
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(new[] { subFolderPath });
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetDirectories(subFolderPath))
.Returns(folders);
var unmappedFolders = Subject.Get(rootFolder.Id, false).UnmappedFolders;
unmappedFolders.Count.Should().Be(3);
}
}
}