Panic Fix
This commit is contained in:
@@ -830,7 +830,8 @@ func uniqueMusicName(stem string, used map[string]struct{}) string {
|
|||||||
}
|
}
|
||||||
for index := 1; ; index++ {
|
for index := 1; ; index++ {
|
||||||
suffix := fmt.Sprintf("_%d", index)
|
suffix := fmt.Sprintf("_%d", index)
|
||||||
candidate := strings.TrimRight(stem[:max(0, maxMusicStemLen-len(suffix))], "_") + suffix
|
prefixLen := min(len(stem), max(0, maxMusicStemLen-len(suffix)))
|
||||||
|
candidate := strings.TrimRight(stem[:prefixLen], "_") + suffix
|
||||||
if _, exists := used[candidate]; exists {
|
if _, exists := used[candidate]; exists {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2609,6 +2609,17 @@ func TestBuildHAKsConvertsMusicSourcesAndWritesCreditsArtifacts(t *testing.T) {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUniqueMusicNameHandlesShortStemCollisions(t *testing.T) {
|
||||||
|
used := map[string]struct{}{
|
||||||
|
"mus_wg_mystc": {},
|
||||||
|
}
|
||||||
|
|
||||||
|
got := uniqueMusicName("mus_wg_mystc", used)
|
||||||
|
if got != "mus_wg_mystc_1" {
|
||||||
|
t.Fatalf("unexpected collision result: got %q want %q", got, "mus_wg_mystc_1")
|
||||||
|
}
|
||||||
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
mustWriteFile(t, filepath.Join(root, "assets", "envi", "music", "westgate", "AleandAnecdotes.mp3"), "source-mp3")
|
mustWriteFile(t, filepath.Join(root, "assets", "envi", "music", "westgate", "AleandAnecdotes.mp3"), "source-mp3")
|
||||||
|
|||||||
Reference in New Issue
Block a user