sort sftp files
All checks were successful
Dev Version / Release (push) Successful in 37s

This commit is contained in:
kekskurse 2023-10-31 17:54:19 +01:00
parent 8fa9c0dd3f
commit 7d1d30eb31

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/pkg/sftp" "github.com/pkg/sftp"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"sort"
"time" "time"
) )
@ -63,6 +64,12 @@ func (f SFTP) ListFiles() ([]File, error) {
fileList = append(fileList, generateFile) fileList = append(fileList, generateFile)
} }
sort.SliceStable(fileList, func(i, j int) bool {
t1, _ := fileList[i].GetTime()
t2, _ := fileList[j].GetTime()
return t1.Before(t2)
})
return fileList, nil return fileList, nil
} }