diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2022-11-25 21:45:47 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-25 08:45:47 -0800 |
| commit | 2b910d1cf8244fdddebd8ff263c701ace9f5434d (patch) | |
| tree | d816acfce7178d2d4825f0db6accd71b2af6bc0f | |
| parent | 4b0430e71d097c0de1f848b09d7aa8b4a74cb4d7 (diff) | |
| download | seaweedfs-2b910d1cf8244fdddebd8ff263c701ace9f5434d.tar.xz seaweedfs-2b910d1cf8244fdddebd8ff263c701ace9f5434d.zip | |
avoid recursive deleting newly created empty directories (#4016)
| -rw-r--r-- | weed/s3api/s3api_objects_list_handlers.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/weed/s3api/s3api_objects_list_handlers.go b/weed/s3api/s3api_objects_list_handlers.go index 65a176617..c1dbafefe 100644 --- a/weed/s3api/s3api_objects_list_handlers.go +++ b/weed/s3api/s3api_objects_list_handlers.go @@ -18,6 +18,8 @@ import ( "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" ) +const cutoffTimeNewEmptyDir = 3 + type ListBucketResultV2 struct { XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult"` Name string `xml:"Name"` @@ -407,11 +409,16 @@ func (s3a *S3ApiServer) ensureDirectoryAllEmpty(filerClient filer_pb.SeaweedFile var startFrom string var isExhausted bool var foundEntry bool + cutOffTimeAtSec := time.Now().Unix() + cutoffTimeNewEmptyDir 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) + if entry.Attributes != nil && cutOffTimeAtSec >= entry.Attributes.GetCrtime() { + fileCounter++ + } else { + subDirs = append(subDirs, entry.Name) + } } else { fileCounter++ } |
