mirror of https://github.com/Radarr/Radarr
This should fix the bug where a folder was tried to be retagged with the same error.
This commit is contained in:
parent
4ae268b8e5
commit
3dd7b3d768
|
@ -9,6 +9,13 @@
|
||||||
</CSS>
|
</CSS>
|
||||||
<CSharp>
|
<CSharp>
|
||||||
<FormatSettings>
|
<FormatSettings>
|
||||||
|
<ALIGN_FIRST_ARG_BY_PAREN>True</ALIGN_FIRST_ARG_BY_PAREN>
|
||||||
|
<ALIGN_MULTILINE_FOR_STMT>False</ALIGN_MULTILINE_FOR_STMT>
|
||||||
|
<CONTINUOUS_INDENT_MULTIPLIER>2</CONTINUOUS_INDENT_MULTIPLIER>
|
||||||
|
<FORCE_ATTRIBUTE_STYLE>SEPARATE</FORCE_ATTRIBUTE_STYLE>
|
||||||
|
<INDENT_NESTED_FIXED_STMT>True</INDENT_NESTED_FIXED_STMT>
|
||||||
|
<INDENT_NESTED_USINGS_STMT>True</INDENT_NESTED_USINGS_STMT>
|
||||||
|
<LINE_FEED_AT_FILE_END>True</LINE_FEED_AT_FILE_END>
|
||||||
<MODIFIERS_ORDER IsNull="False">
|
<MODIFIERS_ORDER IsNull="False">
|
||||||
<Item>public</Item>
|
<Item>public</Item>
|
||||||
<Item>protected</Item>
|
<Item>protected</Item>
|
||||||
|
@ -25,8 +32,30 @@
|
||||||
<Item>unsafe</Item>
|
<Item>unsafe</Item>
|
||||||
<Item>volatile</Item>
|
<Item>volatile</Item>
|
||||||
</MODIFIERS_ORDER>
|
</MODIFIERS_ORDER>
|
||||||
|
<SPACE_AFTER_TYPECAST_PARENTHESES>False</SPACE_AFTER_TYPECAST_PARENTHESES>
|
||||||
|
<SPACE_AROUND_ARROW_OP>True</SPACE_AROUND_ARROW_OP>
|
||||||
|
<SPACE_AROUND_MULTIPLICATIVE_OP>True</SPACE_AROUND_MULTIPLICATIVE_OP>
|
||||||
|
<SPACE_BEFORE_CATCH_PARENTHESES>False</SPACE_BEFORE_CATCH_PARENTHESES>
|
||||||
|
<SPACE_BEFORE_FIXED_PARENTHESES>False</SPACE_BEFORE_FIXED_PARENTHESES>
|
||||||
|
<SPACE_BEFORE_FOR_PARENTHESES>False</SPACE_BEFORE_FOR_PARENTHESES>
|
||||||
|
<SPACE_BEFORE_FOR_SEMICOLON>True</SPACE_BEFORE_FOR_SEMICOLON>
|
||||||
|
<SPACE_BEFORE_FOREACH_PARENTHESES>False</SPACE_BEFORE_FOREACH_PARENTHESES>
|
||||||
|
<SPACE_BEFORE_IF_PARENTHESES>False</SPACE_BEFORE_IF_PARENTHESES>
|
||||||
|
<SPACE_BEFORE_LOCK_PARENTHESES>False</SPACE_BEFORE_LOCK_PARENTHESES>
|
||||||
|
<SPACE_BEFORE_SIZEOF_PARENTHESES>False</SPACE_BEFORE_SIZEOF_PARENTHESES>
|
||||||
|
<SPACE_BEFORE_SWITCH_PARENTHESES>False</SPACE_BEFORE_SWITCH_PARENTHESES>
|
||||||
|
<SPACE_BEFORE_TYPE_PARAMETER_ANGLE>True</SPACE_BEFORE_TYPE_PARAMETER_ANGLE>
|
||||||
|
<SPACE_BEFORE_TYPE_PARAMETER_CONSTRAINT_COLON>False</SPACE_BEFORE_TYPE_PARAMETER_CONSTRAINT_COLON>
|
||||||
|
<SPACE_BEFORE_TYPEOF_PARENTHESES>False</SPACE_BEFORE_TYPEOF_PARENTHESES>
|
||||||
|
<SPACE_BEFORE_USING_PARENTHESES>False</SPACE_BEFORE_USING_PARENTHESES>
|
||||||
|
<SPACE_BEFORE_WHILE_PARENTHESES>False</SPACE_BEFORE_WHILE_PARENTHESES>
|
||||||
|
<STICK_COMMENT>False</STICK_COMMENT>
|
||||||
</FormatSettings>
|
</FormatSettings>
|
||||||
<UsingsSettings />
|
<UsingsSettings>
|
||||||
|
<MandatoryImports IsNull="False">
|
||||||
|
<Item>System.Linq</Item>
|
||||||
|
</MandatoryImports>
|
||||||
|
</UsingsSettings>
|
||||||
<Naming2>
|
<Naming2>
|
||||||
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
|
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
|
||||||
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
|
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
|
||||||
|
@ -79,8 +108,8 @@
|
||||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PublicFields" />
|
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PublicFields" />
|
||||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
|
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
|
||||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
|
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
|
||||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
|
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AA_BB" ElementKind="Constants" />
|
||||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
|
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AA_BB" ElementKind="PrivateConstants" />
|
||||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
|
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
|
||||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
|
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
|
||||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
|
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
[TestCase(@"c:\Root\Test Title", @"c:\Root\_ParseError_Test Title", PostDownloadStatusType.ParseError)]
|
[TestCase(@"c:\Root\Test Title", @"c:\Root\_ParseError_Test Title", PostDownloadStatusType.ParseError)]
|
||||||
public void GetFolderNameWithStatus_should_return_a_string_with_the_error_removing_existing_error(string currentName, string excpectedName, PostDownloadStatusType status)
|
public void GetFolderNameWithStatus_should_return_a_string_with_the_error_removing_existing_error(string currentName, string excpectedName, PostDownloadStatusType status)
|
||||||
{
|
{
|
||||||
PostDownloadProvider.GetFolderNameWithStatus(new DirectoryInfo(currentName), status).Should().Be(
|
PostDownloadProvider.GetTaggedFolderName(new DirectoryInfo(currentName), status).Should().Be(
|
||||||
excpectedName);
|
excpectedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
[ExpectedException(typeof(InvalidOperationException))]
|
[ExpectedException(typeof(InvalidOperationException))]
|
||||||
public void GetFolderNameWithStatus_should_throw_if_status_is_not_an_error(PostDownloadStatusType status)
|
public void GetFolderNameWithStatus_should_throw_if_status_is_not_an_error(PostDownloadStatusType status)
|
||||||
{
|
{
|
||||||
PostDownloadProvider.GetFolderNameWithStatus(new DirectoryInfo(TempFolder), status);
|
PostDownloadProvider.GetTaggedFolderName(new DirectoryInfo(TempFolder), status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\The Office - Season 01");
|
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\The Office - Season 01");
|
||||||
|
|
||||||
var taggedFolder = PostDownloadProvider.GetFolderNameWithStatus(droppedFolder, PostDownloadStatusType.Unknown);
|
var taggedFolder = PostDownloadProvider.GetTaggedFolderName(droppedFolder, PostDownloadStatusType.Unknown);
|
||||||
|
|
||||||
var fakeSeries = Builder<Series>.CreateNew()
|
var fakeSeries = Builder<Series>.CreateNew()
|
||||||
.With(s => s.Title = "The Office")
|
.With(s => s.Title = "The Office")
|
||||||
|
@ -147,6 +147,50 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||||
ExceptionVerification.ExcpectedWarns(1);
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(@"\_UnknownSeries_The Office - S01E01 - Episode Title")]
|
||||||
|
[TestCase(@"\_UnknownSeries_The Office - S01E01 - Episode Title\")]
|
||||||
|
[TestCase("\\Test\\_UnknownSeries_The Office - S01E01 - Episode Title\\")]
|
||||||
|
[TestCase("\\Test\\_UnknownSeries_The Office - S01E01 - Episode Title")]
|
||||||
|
public void folder_shouldnt_be_tagged_with_same_tag_again(string path)
|
||||||
|
{
|
||||||
|
//Setup
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
var droppedFolder = new DirectoryInfo(TempFolder + path);
|
||||||
|
droppedFolder.Create();
|
||||||
|
droppedFolder.LastWriteTime = DateTime.Now.AddHours(-1);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null);
|
||||||
|
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
mocker.GetMock<DiskProvider>().Verify(c => c.MoveDirectory(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void folder_should_be_tagged_if_existing_tag_is_diffrent()
|
||||||
|
{
|
||||||
|
//Setup
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
var droppedFolder = new DirectoryInfo(TempFolder + @"\_UnknownEpisode_The Office - S01E01 - Episode Title");
|
||||||
|
droppedFolder.Create();
|
||||||
|
droppedFolder.LastWriteTime = DateTime.Now.AddHours(-1);
|
||||||
|
|
||||||
|
var taggedFolder = TempFolder + @"\_UnknownSeries_The Office - S01E01 - Episode Title";
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
mocker.GetMock<DiskProvider>().Verify(c => c.MoveDirectory(droppedFolder.FullName, taggedFolder), Times.Once());
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void when_files_are_imported_and_folder_is_small_enought_dir_should_be_deleted()
|
public void when_files_are_imported_and_folder_is_small_enought_dir_should_be_deleted()
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
if (importedFiles.Count == 0)
|
if (importedFiles.Count == 0)
|
||||||
{
|
{
|
||||||
Logger.Warn("Unable to Import new download [{0}], no importable files were found..",
|
Logger.Warn("Unable to Import new download [{0}], no importable files were found.",
|
||||||
subfolderInfo.Name);
|
subfolderInfo.Name);
|
||||||
TagFolder(subfolderInfo, PostDownloadStatusType.ParseError);
|
TagFolder(subfolderInfo, PostDownloadStatusType.ParseError);
|
||||||
}
|
}
|
||||||
|
@ -89,12 +89,17 @@ namespace NzbDrone.Core.Providers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TagFolder(DirectoryInfo directory, PostDownloadStatusType status)
|
private void TagFolder(DirectoryInfo directory, PostDownloadStatusType status)
|
||||||
{
|
{
|
||||||
_diskProvider.MoveDirectory(directory.FullName, GetFolderNameWithStatus(directory, status));
|
var target = GetTaggedFolderName(directory, status);
|
||||||
|
|
||||||
|
if (!String.Equals(Parser.NormalizePath(target), Parser.NormalizePath(directory.FullName), StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
_diskProvider.MoveDirectory(directory.FullName, target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetFolderNameWithStatus(DirectoryInfo directoryInfo, PostDownloadStatusType status)
|
public static string GetTaggedFolderName(DirectoryInfo directoryInfo, PostDownloadStatusType status)
|
||||||
{
|
{
|
||||||
if (status == PostDownloadStatusType.NoError)
|
if (status == PostDownloadStatusType.NoError)
|
||||||
throw new InvalidOperationException("Can't tag a folder with a None-error status. " + status);
|
throw new InvalidOperationException("Can't tag a folder with a None-error status. " + status);
|
||||||
|
|
Loading…
Reference in New Issue