1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-30 11:04:57 +01:00

Prepend a 0 to single-digit track numbers in the organiser. Fixes issue #438

This commit is contained in:
David Sansome 2010-06-25 15:15:02 +00:00
parent 093f198556
commit f0b984cbe9
2 changed files with 21 additions and 0 deletions

View File

@ -139,6 +139,11 @@ QString OrganiseFormat::TagValue(const QString &tag, const Song &song) const {
if (value == "0" || value == "-1") if (value == "0" || value == "-1")
value = ""; value = "";
// Prepend a 0 to single-digit track numbers
if (tag == "track" && value.length() == 1)
value.prepend('0');
return value; return value;
} }

View File

@ -123,3 +123,19 @@ TEST_F(OrganiseFormatTest, ReplaceNonAscii) {
song_.set_artist(QString::fromUtf8("Владимир Высоцкий")); song_.set_artist(QString::fromUtf8("Владимир Высоцкий"));
EXPECT_EQ("________ ________", format_.GetFilenameForSong(song_)); EXPECT_EQ("________ ________", format_.GetFilenameForSong(song_));
} }
TEST_F(OrganiseFormatTest, TrackNumberPadding) {
format_.set_format("%track");
song_.set_track(9);
EXPECT_EQ("09", format_.GetFilenameForSong(song_));
song_.set_track(99);
EXPECT_EQ("99", format_.GetFilenameForSong(song_));
song_.set_track(999);
EXPECT_EQ("999", format_.GetFilenameForSong(song_));
song_.set_track(0);
EXPECT_EQ("", format_.GetFilenameForSong(song_));
}