diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-12-24 11:34:52 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-12-24 11:34:52 -0800 |
| commit | 8e48a235e2e0eb3edaeb30aa82b3c5624d564e01 (patch) | |
| tree | 34428bdb4863f8e77f08121149e2b315ab0b1c9d | |
| parent | 1620de08aea14366a81d55b9db26fc7cf9a7fd67 (diff) | |
| download | seaweedfs-8e48a235e2e0eb3edaeb30aa82b3c5624d564e01.tar.xz seaweedfs-8e48a235e2e0eb3edaeb30aa82b3c5624d564e01.zip | |
s3: avoid looping if the directory is empty
fix https://github.com/chrislusf/seaweedfs/issues/1701
| -rw-r--r-- | weed/s3api/s3api_objects_list_handlers.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/weed/s3api/s3api_objects_list_handlers.go b/weed/s3api/s3api_objects_list_handlers.go index 5c3b898aa..c1c6e2f89 100644 --- a/weed/s3api/s3api_objects_list_handlers.go +++ b/weed/s3api/s3api_objects_list_handlers.go @@ -317,8 +317,10 @@ func (s3a *S3ApiServer) isDirectoryAllEmpty(filerClient filer_pb.SeaweedFilerCli currentDir := parentDir + "/" + name var startFrom string var isExhausted bool + var foundEntry bool for fileCounter == 0 && !isExhausted && err == nil { err = filer_pb.SeaweedList(filerClient, currentDir, "", func(entry *filer_pb.Entry, isLast bool) error { + foundEntry = true if entry.IsDirectory { subDirs = append(subDirs, entry.Name) } else { @@ -329,6 +331,9 @@ func (s3a *S3ApiServer) isDirectoryAllEmpty(filerClient filer_pb.SeaweedFilerCli glog.V(4).Infof(" * %s/%s isLast: %t", currentDir, startFrom, isLast) return nil }, startFrom, false, 8) + if !foundEntry { + break + } } if err != nil { |
