mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-22 07:43:01 +00:00
Fixed: Migrating case-sensitive Preferred Word REGEX to Custom Formats
Closes #5399
This commit is contained in:
parent
0f111dd066
commit
119addd75f
2 changed files with 68 additions and 1 deletions
|
@ -482,6 +482,70 @@ namespace NzbDrone.Core.Test.Datastore.Migration
|
|||
customFormats.First().AnimeEpisodeFormat.Should().Be("{Series Title} - S{season:00}E{episode:00} - {Custom_Formats} {Quality Full}");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_migrate_case_sensitive_regex()
|
||||
{
|
||||
var db = WithMigrationTestDb(c =>
|
||||
{
|
||||
c.Insert.IntoTable("ReleaseProfiles").Row(new
|
||||
{
|
||||
Name = "Profile",
|
||||
Preferred = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
Key = "/somestring/",
|
||||
Value = 2
|
||||
}
|
||||
}.ToJson(),
|
||||
Required = "[]",
|
||||
Ignored = "[]",
|
||||
Tags = "[]",
|
||||
IncludePreferredWhenRenaming = true,
|
||||
Enabled = true,
|
||||
IndexerId = 0
|
||||
});
|
||||
});
|
||||
|
||||
var customFormats = db.Query<CustomFormat171>("SELECT Id, Name, IncludeCustomFormatWhenRenaming, Specifications FROM CustomFormats");
|
||||
|
||||
customFormats.Should().HaveCount(1);
|
||||
customFormats.First().Specifications.Should().HaveCount(1);
|
||||
customFormats.First().Specifications.First().Body.Value.Should().Be("somestring");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_migrate_case_insensitive_regex()
|
||||
{
|
||||
var db = WithMigrationTestDb(c =>
|
||||
{
|
||||
c.Insert.IntoTable("ReleaseProfiles").Row(new
|
||||
{
|
||||
Name = "Profile",
|
||||
Preferred = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
Key = "/somestring/i",
|
||||
Value = 2
|
||||
}
|
||||
}.ToJson(),
|
||||
Required = "[]",
|
||||
Ignored = "[]",
|
||||
Tags = "[]",
|
||||
IncludePreferredWhenRenaming = true,
|
||||
Enabled = true,
|
||||
IndexerId = 0
|
||||
});
|
||||
});
|
||||
|
||||
var customFormats = db.Query<CustomFormat171>("SELECT Id, Name, IncludeCustomFormatWhenRenaming, Specifications FROM CustomFormats");
|
||||
|
||||
customFormats.Should().HaveCount(1);
|
||||
customFormats.First().Specifications.Should().HaveCount(1);
|
||||
customFormats.First().Specifications.First().Body.Value.Should().Be("somestring");
|
||||
}
|
||||
|
||||
private class NamingConfig171
|
||||
{
|
||||
public string StandardEpisodeFormat { get; set; }
|
||||
|
|
|
@ -101,7 +101,10 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||
|
||||
foreach (var term in data)
|
||||
{
|
||||
var regexTerm = term.Key.TrimStart('/').TrimEnd("/i");
|
||||
var regexTerm = term.Key
|
||||
.TrimStart('/')
|
||||
.TrimEnd('/')
|
||||
.TrimEnd("/i");
|
||||
|
||||
// Validate Regex before creating a CF
|
||||
try
|
||||
|
|
Loading…
Reference in a new issue