mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-08 00:22:14 +01:00
fix(pdfcpu): correct sorting for the output paths of the split method
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
@@ -128,11 +129,25 @@ func (engine *PdfCpu) Split(ctx context.Context, logger *zap.Logger, mode gotenb
|
||||
return nil, fmt.Errorf("split PDFs with pdfcpu: %w", err)
|
||||
}
|
||||
|
||||
outputPaths, err := gotenberg.WalkDir(outputDirPath, ".pdf")
|
||||
var outputPaths []string
|
||||
err = filepath.Walk(outputDirPath, func(path string, info os.FileInfo, pathErr error) error {
|
||||
if pathErr != nil {
|
||||
return pathErr
|
||||
}
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
if strings.EqualFold(filepath.Ext(info.Name()), ".pdf") {
|
||||
outputPaths = append(outputPaths, path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("walk directory to find resulting PDFs from split with pdfcpu: %w", err)
|
||||
}
|
||||
|
||||
sort.Sort(gotenberg.AlphanumericSort(outputPaths))
|
||||
|
||||
return outputPaths, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user