Fix s3.clean.uploads (#4766)

This commit is contained in:
SmsS4 2023-08-19 17:00:18 +03:30 committed by GitHub
parent 710e88f713
commit 1e72579ac7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,13 +3,14 @@ package shell
import ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
"github.com/seaweedfs/seaweedfs/weed/security"
"github.com/seaweedfs/seaweedfs/weed/util"
"io" "io"
"math" "math"
"time" "time"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
"github.com/seaweedfs/seaweedfs/weed/security"
"github.com/seaweedfs/seaweedfs/weed/util"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
) )
@ -17,8 +18,7 @@ func init() {
Commands = append(Commands, &commandS3CleanUploads{}) Commands = append(Commands, &commandS3CleanUploads{})
} }
type commandS3CleanUploads struct { type commandS3CleanUploads struct{}
}
func (c *commandS3CleanUploads) Name() string { func (c *commandS3CleanUploads) Name() string {
return "s3.clean.uploads" return "s3.clean.uploads"
@ -34,14 +34,13 @@ func (c *commandS3CleanUploads) Help() string {
} }
func (c *commandS3CleanUploads) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) { func (c *commandS3CleanUploads) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
bucketCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) bucketCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
uploadedTimeAgo := bucketCommand.Duration("timeAgo", 24*time.Hour, "created time before now. \"1.5h\" or \"2h45m\". Valid time units are \"m\", \"h\"") uploadedTimeAgo := bucketCommand.Duration("timeAgo", 24*time.Hour, "created time before now. \"1.5h\" or \"2h45m\". Valid time units are \"m\", \"h\"")
if err = bucketCommand.Parse(args); err != nil { if err = bucketCommand.Parse(args); err != nil {
return nil return nil
} }
signingKey := util.GetViper().GetString("jwt.signing.key") signingKey := util.GetViper().GetString("jwt.filer_signing.key")
var filerBucketsPath string var filerBucketsPath string
filerBucketsPath, err = readFilerBucketsPath(commandEnv) filerBucketsPath, err = readFilerBucketsPath(commandEnv)
@ -65,7 +64,6 @@ func (c *commandS3CleanUploads) Do(args []string, commandEnv *CommandEnv, writer
} }
return err return err
} }
func (c *commandS3CleanUploads) cleanupUploads(commandEnv *CommandEnv, writer io.Writer, filerBucketsPath string, bucket string, timeAgo time.Duration, signingKey string) error { func (c *commandS3CleanUploads) cleanupUploads(commandEnv *CommandEnv, writer io.Writer, filerBucketsPath string, bucket string, timeAgo time.Duration, signingKey string) error {
@ -99,5 +97,4 @@ func (c *commandS3CleanUploads) cleanupUploads(commandEnv *CommandEnv, writer io
} }
return nil return nil
} }