mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: Migration would add double underscores for format tags without modifiers. Also fixed Radarr misparsing those tags and added migration to correct this.
This commit is contained in:
parent
bf7689688d
commit
b2d6ef589f
@ -35,6 +35,7 @@ public class QualityTagFixture : CoreTest
|
|||||||
[TestCase("G_10<>20", TagType.Size, new[] { 10737418240L, 21474836480L})]
|
[TestCase("G_10<>20", TagType.Size, new[] { 10737418240L, 21474836480L})]
|
||||||
[TestCase("G_15.55<>20", TagType.Size, new[] { 16696685363L, 21474836480L})]
|
[TestCase("G_15.55<>20", TagType.Size, new[] { 16696685363L, 21474836480L})]
|
||||||
[TestCase("G_15.55<>25.1908754", TagType.Size, new[] { 16696685363L, 27048496500L})]
|
[TestCase("G_15.55<>25.1908754", TagType.Size, new[] { 16696685363L, 27048496500L})]
|
||||||
|
[TestCase("R__1080", TagType.Resolution, Resolution.R1080P)]
|
||||||
public void should_parse_tag_from_string(string raw, TagType type, object value, params TagModifier[] modifiers)
|
public void should_parse_tag_from_string(string raw, TagType type, object value, params TagModifier[] modifiers)
|
||||||
{
|
{
|
||||||
var parsed = new FormatTag(raw);
|
var parsed = new FormatTag(raw);
|
||||||
|
@ -32,6 +32,7 @@ public void AddCustomFormat(convert_regex_required_tags c, string name, params s
|
|||||||
[TestCase("C_RE_RERN", "C_RQ_RERN")]
|
[TestCase("C_RE_RERN", "C_RQ_RERN")]
|
||||||
[TestCase("E_NRER_Director", "E_NRXRQ_Director")]
|
[TestCase("E_NRER_Director", "E_NRXRQ_Director")]
|
||||||
[TestCase("G_N_1000<>1000", "G_N_1000<>1000")]
|
[TestCase("G_N_1000<>1000", "G_N_1000<>1000")]
|
||||||
|
[TestCase("G_1000<>1000", "G_1000<>1000")]
|
||||||
public void should_correctly_convert_format_tag(string original, string converted)
|
public void should_correctly_convert_format_tag(string original, string converted)
|
||||||
{
|
{
|
||||||
var db = WithMigrationTestDb(c => { AddCustomFormat(c, "TestFormat", original); });
|
var db = WithMigrationTestDb(c => { AddCustomFormat(c, "TestFormat", original); });
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Common.Serializer;
|
||||||
|
using NzbDrone.Core.Datastore.Migration;
|
||||||
|
using NzbDrone.Core.Parser;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.Datastore.Migration
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class fix_format_tags_double_underscoreFixture : MigrationTest<fix_format_tags_double_underscore>
|
||||||
|
{
|
||||||
|
|
||||||
|
public void AddCustomFormat(fix_format_tags_double_underscore c, string name, params string[] formatTags)
|
||||||
|
{
|
||||||
|
var customFormat = new {Name = name, FormatTags = formatTags.ToList().ToJson()};
|
||||||
|
|
||||||
|
c.Insert.IntoTable("CustomFormats").Row(customFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("C_HDR", "C_HDR")]
|
||||||
|
[TestCase("C__HDR", "C_HDR")]
|
||||||
|
[TestCase("C_RXRQ_HDR", "C_RXRQ_HDR")]
|
||||||
|
[TestCase("C_RENR_HDR", "C_RENR_HDR")]
|
||||||
|
[TestCase("E__Director", "E_Director")]
|
||||||
|
[TestCase("G_N_1000<>1000", "G_N_1000<>1000")]
|
||||||
|
[TestCase("G_1000<>1000", "G_1000<>1000")]
|
||||||
|
public void should_correctly_convert_format_tag(string original, string converted)
|
||||||
|
{
|
||||||
|
var db = WithMigrationTestDb(c => { AddCustomFormat(c, "TestFormat", original); });
|
||||||
|
|
||||||
|
var items = QueryItems(db);
|
||||||
|
|
||||||
|
var convertedTags = items.First().DeserializedTags;
|
||||||
|
|
||||||
|
convertedTags.Should().HaveCount(1);
|
||||||
|
convertedTags.First().ShouldBeEquivalentTo(converted);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<regex_required_tagsFixture.CustomFormatTest149> QueryItems(IDirectDataMapper db)
|
||||||
|
{
|
||||||
|
var items = db.Query<regex_required_tagsFixture.CustomFormatTest149>("SELECT Name, FormatTags FROM CustomFormats");
|
||||||
|
|
||||||
|
return items.Select(i =>
|
||||||
|
{
|
||||||
|
i.DeserializedTags = JsonConvert.DeserializeObject<List<string>>(i.FormatTags);
|
||||||
|
return i;
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -140,6 +140,7 @@
|
|||||||
<Compile Include="Datastore\Migration\090_update_kickass_urlFixture.cs" />
|
<Compile Include="Datastore\Migration\090_update_kickass_urlFixture.cs" />
|
||||||
<Compile Include="Datastore\Migration\147_custom_formatsFixture.cs" />
|
<Compile Include="Datastore\Migration\147_custom_formatsFixture.cs" />
|
||||||
<Compile Include="Datastore\Migration\149_regex_required_tagsFixture.cs" />
|
<Compile Include="Datastore\Migration\149_regex_required_tagsFixture.cs" />
|
||||||
|
<Compile Include="Datastore\Migration\150_fix_format_tags_double_underscoreFixture.cs" />
|
||||||
<Compile Include="Datastore\ObjectDatabaseFixture.cs" />
|
<Compile Include="Datastore\ObjectDatabaseFixture.cs" />
|
||||||
<Compile Include="Datastore\PagingSpecExtensionsTests\PagingOffsetFixture.cs" />
|
<Compile Include="Datastore\PagingSpecExtensionsTests\PagingOffsetFixture.cs" />
|
||||||
<Compile Include="Datastore\PagingSpecExtensionsTests\ToSortDirectionFixture.cs" />
|
<Compile Include="Datastore\PagingSpecExtensionsTests\ToSortDirectionFixture.cs" />
|
||||||
|
@ -15,7 +15,7 @@ public class FormatTag
|
|||||||
public TagModifier TagModifier { get; set; }
|
public TagModifier TagModifier { get; set; }
|
||||||
public object Value { get; set; }
|
public object Value { get; set; }
|
||||||
|
|
||||||
public static Regex QualityTagRegex = new Regex(@"^(?<type>R|S|M|E|L|C|I|G)(_((?<m_r>RX)|(?<m_re>RQ)|(?<m_n>N)){1,3})?_(?<value>.*)$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
public static Regex QualityTagRegex = new Regex(@"^(?<type>R|S|M|E|L|C|I|G)(_((?<m_r>RX)|(?<m_re>RQ)|(?<m_n>N)){0,3})?_(?<value>.*)$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
public static Regex SizeTagRegex = new Regex(@"(?<min>\d+(\.\d+)?)\s*<>\s*(?<max>\d+(\.\d+)?)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
public static Regex SizeTagRegex = new Regex(@"(?<min>\d+(\.\d+)?)\s*<>\s*(?<max>\d+(\.\d+)?)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ private void ConvertExistingFormatTags(IDbConnection conn, IDbTransaction tran)
|
|||||||
if (match.Groups["m_n"].Success) modifiers += "N";
|
if (match.Groups["m_n"].Success) modifiers += "N";
|
||||||
if (match.Groups["m_r"].Success) modifiers += "RX";
|
if (match.Groups["m_r"].Success) modifiers += "RX";
|
||||||
if (match.Groups["m_re"].Success) modifiers += "RQ";
|
if (match.Groups["m_re"].Success) modifiers += "RQ";
|
||||||
return $"{match.Groups["type"].Value}_{modifiers}_{match.Groups["value"].Value}";
|
if (modifiers != "") modifiers = "_" + modifiers;
|
||||||
|
return $"{match.Groups["type"].Value}{modifiers}_{match.Groups["value"].Value}";
|
||||||
});
|
});
|
||||||
|
|
||||||
updater.Commit();
|
updater.Commit();
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using FluentMigrator;
|
||||||
|
using NzbDrone.Common.Serializer;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(150)]
|
||||||
|
public class fix_format_tags_double_underscore : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
public static Regex DoubleUnderscore = new Regex(@"^(?<type>R|S|M|E|L|C|I|G)__(?<value>.*)$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
Execute.WithConnection(ConvertExistingFormatTags);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConvertExistingFormatTags(IDbConnection conn, IDbTransaction tran)
|
||||||
|
{
|
||||||
|
var updater = new CustomFormatUpdater149(conn, tran);
|
||||||
|
|
||||||
|
updater.ReplaceInTags(DoubleUnderscore, match =>
|
||||||
|
{
|
||||||
|
return $"{match.Groups["type"].Value}_{match.Groups["value"].Value}";
|
||||||
|
});
|
||||||
|
|
||||||
|
updater.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -145,6 +145,7 @@
|
|||||||
<Compile Include="Datastore\Migration\145_banner_to_fanart.cs" />
|
<Compile Include="Datastore\Migration\145_banner_to_fanart.cs" />
|
||||||
<Compile Include="Datastore\Migration\144_add_cookies_to_indexer_status.cs" />
|
<Compile Include="Datastore\Migration\144_add_cookies_to_indexer_status.cs" />
|
||||||
<Compile Include="Datastore\Migration\149_convert_regex_required_tags.cs" />
|
<Compile Include="Datastore\Migration\149_convert_regex_required_tags.cs" />
|
||||||
|
<Compile Include="Datastore\Migration\150_fix_format_tags_double_underscore.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\CustomFormatAllowedByProfileSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\CustomFormatAllowedByProfileSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\MaximumSizeSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\MaximumSizeSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\RequiredIndexerFlagsSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\RequiredIndexerFlagsSpecification.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user