fix(podcast): truncate filenames longer than 200 chars

fixes #624
This commit is contained in:
sentriz
2025-11-05 12:10:32 -03:00
parent c2ebe96313
commit e12ab544c2
3 changed files with 24 additions and 3 deletions

No files matched your search

+5 -1
View File
@@ -14,9 +14,13 @@ import (
var nonAlphaNumExpr = regexp.MustCompile("[^a-zA-Z0-9_.]+")
const maxFilenameLength = 200
func Safe(filename string) string {
filename = nonAlphaNumExpr.ReplaceAllString(filename, "")
return filename
ext := filepath.Ext(filename)
filename = filename[:min(maxFilenameLength, len(filename))-len(ext)]
return filename + ext
}
// try to find a unqiue file (or dir) name. incrementing like "example (1)"