SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
correctly determine whether a folder is empty
Chris Lu5c465293e91f
diff --git a/weed/s3api/s3api_objects_list_handlers.go b/weed/s3api/s3api_objects_list_handlers.goindex eea06a08a2..dce2fd6b0a 100644--- a/weed/s3api/s3api_objects_list_handlers.go+++ b/weed/s3api/s3api_objects_list_handlers.go@@ -4,6 +4,7 @@ import ("context""encoding/xml""fmt"+ "github.com/chrislusf/seaweedfs/weed/glog""io""net/http""net/url"@@ -311,16 +312,21 @@ func (s3a *S3ApiServer) isDirectoryAllEmpty(filerClient filer_pb.SeaweedFilerCli// println("+ isDirectoryAllEmpty", dir, name)var fileCounter intvar subDirs []string- currentDir := parentDir+"/"+name- err = filer_pb.SeaweedList(filerClient, currentDir, "", func(entry *filer_pb.Entry, isLast bool) error {- if entry.IsDirectory {- subDirs = append(subDirs, entry.Name)- } else {- println("existing file", currentDir, entry.Name)- fileCounter++- }- return nil- }, "",false, 32)+ currentDir := parentDir + "/" + name+ var startFrom string+ var isExhausted bool+ for fileCounter == 0 && !isExhausted {+ err = filer_pb.SeaweedList(filerClient, currentDir, "", func(entry *filer_pb.Entry, isLast bool) error {+ if entry.IsDirectory {+ subDirs = append(subDirs, entry.Name)+ } else {+ fileCounter+++ }+ startFrom = entry.Name+ isExhausted = isExhausted || isLast+ return nil+ }, startFrom, false, 8)+ }if err != nil {return false, err@@ -340,7 +346,7 @@ func (s3a *S3ApiServer) isDirectoryAllEmpty(filerClient filer_pb.SeaweedFilerCli}}- println("deleting empty", currentDir)+ glog.V(1).Infof("deleting empty folder %s", currentDir)if err = doDeleteEntry(filerClient, parentDir, name, true, true); err != nil {return}