This commit is contained in:
parent
8fa9c0dd3f
commit
7d1d30eb31
1 changed files with 7 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/pkg/sftp"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -63,6 +64,12 @@ func (f SFTP) ListFiles() ([]File, error) {
|
|||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue