improve fmt part, using consistant size

This commit is contained in:
Celogeek 2023-04-11 17:35:14 +02:00
parent afc3355e0d
commit 5276f2ba6f
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc

View File

@ -247,7 +247,9 @@ func (e *ePub) Write() error {
ext := filepath.Ext(e.Output)
suffix := ""
if totalParts > 1 {
suffix = fmt.Sprintf(" Part %02d of %02d", i+1, totalParts)
fmtLen := len(fmt.Sprint(totalParts))
fmtPart := fmt.Sprintf(" Part %%0%dd of %%0%dd", fmtLen, fmtLen)
suffix = fmt.Sprintf(fmtPart, i+1, totalParts)
}
path := fmt.Sprintf("%s%s%s", e.Output[0:len(e.Output)-len(ext)], suffix, ext)