diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-12-13 00:22:37 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-12-13 00:22:37 -0800 |
| commit | 0fa1269bc77abe30f4d108a88a97e29e1bca3124 (patch) | |
| tree | 5cc1c65ea9119dc23a5a4ded21e775d62c1bf9f3 /weed/s3api/filer_util.go | |
| parent | d0b423bbc07368bc53a08aec47618924851725a1 (diff) | |
| download | seaweedfs-0fa1269bc77abe30f4d108a88a97e29e1bca3124.tar.xz seaweedfs-0fa1269bc77abe30f4d108a88a97e29e1bca3124.zip | |
filer: streaming file listing
Diffstat (limited to 'weed/s3api/filer_util.go')
| -rw-r--r-- | weed/s3api/filer_util.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/weed/s3api/filer_util.go b/weed/s3api/filer_util.go index b93b603e2..ed9612d35 100644 --- a/weed/s3api/filer_util.go +++ b/weed/s3api/filer_util.go @@ -3,6 +3,7 @@ package s3api import ( "context" "fmt" + "io" "os" "strings" "time" @@ -89,13 +90,25 @@ func (s3a *S3ApiServer) list(ctx context.Context, parentDirectoryPath, prefix, s } glog.V(4).Infof("read directory: %v", request) - resp, err := client.ListEntries(ctx, request) + stream, err := client.ListEntries(ctx, request) if err != nil { glog.V(0).Infof("read directory %v: %v", request, err) return fmt.Errorf("list dir %v: %v", parentDirectoryPath, err) } - entries = resp.Entries + for { + resp, recvErr := stream.Recv() + if recvErr != nil { + if recvErr == io.EOF { + break + } else { + return recvErr + } + } + + entries = append(entries, resp.Entry) + + } return nil }) |
