Remove _UNPACK_ and _FAILED_ from folder name before processing

pull/3113/head
Mark McDowall 11 years ago
parent 483b39899e
commit fa5dda8e2f

@ -141,6 +141,26 @@ namespace NzbDrone.Core.Test.MediaFileTests
.Verify(v => v.DeleteFolder(It.IsAny<String>(), true), Times.Once());
}
[TestCase("_UNPACK_")]
[TestCase("_FAILED_")]
public void should_remove_unpack_from_folder_name(string prefix)
{
var folderName = "30.rock.s01e01.pilot.hdtv-lol";
var folders = new[] { String.Format(@"C:\Test\Unsorted\{0}{1}", prefix, folderName) };
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.GetDirectories(It.IsAny<string>()))
.Returns(folders);
Subject.Execute(new DownloadedEpisodesScanCommand());
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetSeries(folderName), Times.Once());
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetSeries(It.Is<String>(s => s.StartsWith(prefix))), Times.Never());
}
private void VerifyNoImport()
{
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true),

@ -101,11 +101,12 @@ namespace NzbDrone.Core.MediaFiles
private List<ImportDecision> ProcessSubFolder(DirectoryInfo subfolderInfo)
{
var series = _parsingService.GetSeries(subfolderInfo.Name);
var cleanedUpName = GetCleanedUpFolderName(subfolderInfo.Name);
var series = _parsingService.GetSeries(cleanedUpName);
if (series == null)
{
_logger.Debug("Unknown Series {0}", subfolderInfo.Name);
_logger.Debug("Unknown Series {0}", cleanedUpName);
return new List<ImportDecision>();
}
@ -139,6 +140,14 @@ namespace NzbDrone.Core.MediaFiles
return _importApprovedEpisodes.Import(decisions, true);
}
private string GetCleanedUpFolderName(string folder)
{
folder = folder.Replace("_UNPACK_", "")
.Replace("_FAILED_", "");
return folder;
}
public void Execute(DownloadedEpisodesScanCommand message)
{
ProcessDownloadedEpisodesFolder();

Loading…
Cancel
Save