- commit
- 757ccfd
- parent
- d0ea3e0
- author
- Eric Bower
- date
- 2023-08-12 14:53:51 +0000 UTC
fix: sftp `ListFiles` It previously wasn't returning something that sftp was expecting
2 files changed,
+13,
-9
1@@ -6,7 +6,7 @@ import (
2 "fmt"
3 "net/url"
4 "os"
5- "path"
6+ "strings"
7
8 "github.com/minio/madmin-go/v3"
9 "github.com/minio/minio-go/v7"
10@@ -97,11 +97,19 @@ func (s *StorageMinio) GetBucketQuota(bucket Bucket) (uint64, error) {
11
12 func (s *StorageMinio) ListFiles(bucket Bucket, dir string) ([]os.FileInfo, error) {
13 var fileList []os.FileInfo
14- objs := s.Client.ListObjects(context.TODO(), bucket.Name, minio.ListObjectsOptions{Prefix: dir})
15- for obj := range objs {
16+
17+ opts := minio.ListObjectsOptions{Prefix: dir, Recursive: false}
18+ for obj := range s.Client.ListObjects(context.TODO(), bucket.Name, opts) {
19+ if obj.Err != nil {
20+ fmt.Println(obj.Err)
21+ }
22+ isDir := false
23+ if obj.Size == 0 {
24+ isDir = true
25+ }
26 info := &utils.VirtualFile{
27- FName: path.Join(dir, obj.Key),
28- FIsDir: false,
29+ FName: strings.TrimSuffix(obj.Key, "/"),
30+ FIsDir: isDir,
31 FSize: obj.Size,
32 FModTime: obj.LastModified,
33 }
+0,
-4
1@@ -43,10 +43,6 @@ func (f *handler) Filelist(r *sftp.Request) (sftp.ListerAt, error) {
2 return nil, err
3 }
4
5- if r.Method == "List" {
6- listData = listData[1:]
7- }
8-
9 return listerat(listData), nil
10 }
11