aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2023-04-25 20:31:14 +0500
committerGitHub <noreply@github.com>2023-04-25 08:31:14 -0700
commitd75a7b7f624910e6b0c8be293483ad13b52d1aa5 (patch)
treed70148a77ae637886c2c832d3c109184f25d2644 /weed/s3api
parentfafff5896ef8783613ba329e9c2d3b076a11e8fa (diff)
downloadseaweedfs-d75a7b7f624910e6b0c8be293483ad13b52d1aa5.tar.xz
seaweedfs-d75a7b7f624910e6b0c8be293483ad13b52d1aa5.zip
allow deleting only older empty dir without recursion (#4430)
Diffstat (limited to 'weed/s3api')
-rw-r--r--weed/s3api/s3api_objects_list_handlers.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/weed/s3api/s3api_objects_list_handlers.go b/weed/s3api/s3api_objects_list_handlers.go
index d0862f652..8b1776ae6 100644
--- a/weed/s3api/s3api_objects_list_handlers.go
+++ b/weed/s3api/s3api_objects_list_handlers.go
@@ -18,8 +18,6 @@ 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"`
@@ -391,7 +389,7 @@ func (s3a *S3ApiServer) doListFilerEntries(client filer_pb.SeaweedFilerClient, d
// println("doListFilerEntries2 nextMarker", nextMarker)
} else {
var isEmpty bool
- if !s3a.option.AllowEmptyFolder && !entry.IsDirectoryKeyObject() {
+ if !s3a.option.AllowEmptyFolder && entry.IsOlderDir() {
if isEmpty, err = s3a.ensureDirectoryAllEmpty(client, dir, entry.Name); err != nil {
glog.Errorf("check empty folder %s: %v", dir, err)
}
@@ -447,16 +445,11 @@ 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 {
- if entry.Attributes != nil && cutOffTimeAtSec >= entry.Attributes.GetCrtime() {
- fileCounter++
- } else {
- subDirs = append(subDirs, entry.Name)
- }
+ if entry.IsOlderDir() {
+ subDirs = append(subDirs, entry.Name)
} else {
fileCounter++
}
@@ -489,7 +482,7 @@ func (s3a *S3ApiServer) ensureDirectoryAllEmpty(filerClient filer_pb.SeaweedFile
}
glog.V(1).Infof("deleting empty folder %s", currentDir)
- if err = doDeleteEntry(filerClient, parentDir, name, true, true); err != nil {
+ if err = doDeleteEntry(filerClient, parentDir, name, true, false); err != nil {
return
}