1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-24 08:42:19 +02:00

Fixed: Replace illegal characters even when renaming is disabled

Closes #7183
This commit is contained in:
Mark McDowall 2024-09-05 20:46:10 -07:00
parent 992eec5cec
commit 418c01ac2a
2 changed files with 17 additions and 3 deletions

View File

@ -274,7 +274,7 @@ public void use_path_when_sceneName_and_relative_path_are_null()
{
_namingConfig.RenameEpisodes = false;
_episodeFile.RelativePath = null;
_episodeFile.Path = @"C:\Test\Unsorted\Series - S01E01 - Test";
_episodeFile.Path = @"C:\Test\Unsorted\Series - S01E01 - Test".AsOsAgnostic();
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
.Should().Be(Path.GetFileNameWithoutExtension(_episodeFile.Path));
@ -291,6 +291,20 @@ public void use_file_name_when_sceneName_is_not_null()
.Should().Be("30.Rock.S01E01.xvid-LOL");
}
[Test]
public void should_replace_illegal_characters_when_renaming_is_disabled()
{
_namingConfig.RenameEpisodes = false;
_namingConfig.ReplaceIllegalCharacters = true;
_namingConfig.ColonReplacementFormat = ColonReplacementFormat.Smart;
_episodeFile.SceneName = "30.Rock.S01E01.xvid:LOL";
_episodeFile.RelativePath = "30 Rock - S01E01 - Test";
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
.Should().Be("30.Rock.S01E01.xvid-LOL");
}
[Test]
public void should_use_airDate_if_series_isDaily_and_not_a_special()
{

View File

@ -1116,10 +1116,10 @@ private string GetOriginalTitle(EpisodeFile episodeFile, bool useCurrentFilename
{
if (episodeFile.SceneName.IsNullOrWhiteSpace())
{
return GetOriginalFileName(episodeFile, useCurrentFilenameAsFallback);
return CleanFileName(GetOriginalFileName(episodeFile, useCurrentFilenameAsFallback));
}
return episodeFile.SceneName;
return CleanFileName(episodeFile.SceneName);
}
private string GetOriginalFileName(EpisodeFile episodeFile, bool useCurrentFilenameAsFallback)