Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Trim all leading dots from nested folders (#2371) #2372

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -29,11 +29,11 @@ public void Setup()
{
_artist = Builder<Artist>
.CreateNew()
.With(s => s.Name = "Linkin Park")
.With(s => s.Name = "Metallica")
.With(s => s.Metadata = new ArtistMetadata
{
Disambiguation = "US Rock Band",
Name = "Linkin Park"
Disambiguation = "US Metal Band",
Name = "Metallica"
})
.Build();

Expand All @@ -55,7 +55,7 @@ public void Setup()

_album = Builder<Album>
.CreateNew()
.With(s => s.Title = "Hybrid Theory")
.With(s => s.Title = "...And Justice For All")
.With(s => s.ReleaseDate = new DateTime(2020, 1, 15))
.With(s => s.AlbumType = "Album")
.With(s => s.Disambiguation = "The Best Album")
Expand Down Expand Up @@ -97,7 +97,7 @@ public void should_build_nested_standard_track_filename_with_forward_slash()
_namingConfig.StandardTrackFormat = "{Album Title} {(Release Year)}/{Artist Name} - {track:00} [{Quality Title}] {[Quality Proper]}";

Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
.Should().Be("Hybrid Theory (2020)\\Linkin Park - 06 [MP3-256]".AsOsAgnostic());
.Should().Be("And Justice For All (2020)\\Metallica - 06 [MP3-256]".AsOsAgnostic());
}

[Test]
Expand All @@ -106,7 +106,7 @@ public void should_build_nested_standard_track_filename_with_back_slash()
_namingConfig.StandardTrackFormat = "{Album Title} {(Release Year)}\\{Artist Name} - {track:00} [{Quality Title}] {[Quality Proper]}";

Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
.Should().Be("Hybrid Theory (2020)\\Linkin Park - 06 [MP3-256]".AsOsAgnostic());
.Should().Be("And Justice For All (2020)\\Metallica - 06 [MP3-256]".AsOsAgnostic());
}

[Test]
Expand All @@ -117,7 +117,7 @@ public void should_build_nested_multi_track_filename_with_forward_slash()
_release.Media.Add(_medium2);

Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
.Should().Be("Hybrid Theory (2020)\\CD 03\\Linkin Park - 06 [MP3-256]".AsOsAgnostic());
.Should().Be("And Justice For All (2020)\\CD 03\\Metallica - 06 [MP3-256]".AsOsAgnostic());
}

[Test]
Expand All @@ -128,7 +128,7 @@ public void should_build_nested_multi_track_filename_with_back_slash()
_release.Media.Add(_medium2);

Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
.Should().Be("Hybrid Theory (2020)\\CD 03\\Linkin Park - 06 [MP3-256]".AsOsAgnostic());
.Should().Be("And Justice For All (2020)\\CD 03\\Metallica - 06 [MP3-256]".AsOsAgnostic());
}
}
}
2 changes: 1 addition & 1 deletion src/NzbDrone.Core/Organizer/FileNameBuilder.cs
Expand Up @@ -131,7 +131,7 @@ public string BuildTrackFileName(List<Track> tracks, Artist artist, Album album,

var component = ReplaceTokens(splitPattern, tokenHandlers, namingConfig).Trim();

component = FileNameCleanupRegex.Replace(component, match => match.Captures[0].Value[0].ToString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than this change, would it be better to modify the 'CleanFolderName' method to trim leading "." characters? Then if a user would like to keep the leading "." they can use {Album Title}, but trimming is available with {Album CleanTitle} or any of the other 'clean' tags.

component = CleanFolderName(component);
component = TrimSeparatorsRegex.Replace(component, string.Empty);

if (component.IsNotNullOrWhiteSpace())
Expand Down