diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2021-03-11 20:58:58 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-11 20:58:58 -0800 |
| commit | 5f99eee27c0f48ebc10e79241650be3727124af2 (patch) | |
| tree | 0b80a2d7bc9fd99d7b68e8c06080a9a062fffd35 | |
| parent | cca66c7fbe883480c9935ec1f5fe469ee35dae0b (diff) | |
| parent | 4c1d945e46d280c7e38eb7fe759c57519ba9140e (diff) | |
| download | seaweedfs-5f99eee27c0f48ebc10e79241650be3727124af2.tar.xz seaweedfs-5f99eee27c0f48ebc10e79241650be3727124af2.zip | |
Merge pull request #1892 from wuh-fnst/listMultipartIsLast
make “List” correctly judge whether it is the last file
| -rw-r--r-- | weed/pb/filer_pb/filer_client.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/weed/pb/filer_pb/filer_client.go b/weed/pb/filer_pb/filer_client.go index 079fbd671..e4d8bee34 100644 --- a/weed/pb/filer_pb/filer_client.go +++ b/weed/pb/filer_pb/filer_client.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "math" "os" "strings" "time" @@ -101,12 +102,16 @@ func SeaweedList(client SeaweedFilerClient, parentDirectoryPath, prefix string, } func doSeaweedList(client SeaweedFilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunciton, startFrom string, inclusive bool, limit uint32) (err error) { - + // Redundancy limit to make it correctly judge whether it is the last file. + redLimit := limit + if limit != math.MaxInt32 && limit != 0{ + redLimit = limit + 1 + } request := &ListEntriesRequest{ Directory: string(fullDirPath), Prefix: prefix, StartFromFileName: startFrom, - Limit: limit, + Limit: redLimit, InclusiveStartFrom: inclusive, } @@ -119,6 +124,7 @@ func doSeaweedList(client SeaweedFilerClient, fullDirPath util.FullPath, prefix } var prevEntry *Entry + count := 0 for { resp, recvErr := stream.Recv() if recvErr != nil { @@ -139,6 +145,10 @@ func doSeaweedList(client SeaweedFilerClient, fullDirPath util.FullPath, prefix } } prevEntry = resp.Entry + count++ + if count > int(limit) && limit != 0 { + prevEntry = nil + } } return nil |
