From fb3c9ed80d37a08dcf9f8f6a926e7734816a2a63 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 22 Nov 2019 01:39:50 -0800 Subject: [PATCH] shell: fs.meta.save missed directory data with more than 1024 entries fix https://github.com/chrislusf/seaweedfs/issues/1130 --- weed/server/filer_grpc_server.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/weed/server/filer_grpc_server.go b/weed/server/filer_grpc_server.go index 9c35e8846..feab11c79 100644 --- a/weed/server/filer_grpc_server.go +++ b/weed/server/filer_grpc_server.go @@ -40,11 +40,16 @@ func (fs *FilerServer) ListEntries(ctx context.Context, req *filer_pb.ListEntrie limit = fs.option.DirListingLimit } + paginationLimit := 1024 + if limit < paginationLimit { + paginationLimit = limit + } + resp := &filer_pb.ListEntriesResponse{} lastFileName := req.StartFromFileName includeLastFile := req.InclusiveStartFrom for limit > 0 { - entries, err := fs.filer.ListDirectoryEntries(ctx, filer2.FullPath(req.Directory), lastFileName, includeLastFile, 1024) + entries, err := fs.filer.ListDirectoryEntries(ctx, filer2.FullPath(req.Directory), lastFileName, includeLastFile, paginationLimit) if err != nil { return nil, err } @@ -71,9 +76,12 @@ func (fs *FilerServer) ListEntries(ctx context.Context, req *filer_pb.ListEntrie Attributes: filer2.EntryAttributeToPb(entry), }) limit-- + if limit == 0 { + return resp, nil + } } - if len(resp.Entries) < 1024 { + if len(entries) < paginationLimit { break }