Skip to content

Commit

Permalink
Allow to disable optional initialization steps: --no-multipart-expire…
Browse files Browse the repository at this point in the history
… --no-detect
  • Loading branch information
vitalif committed Aug 12, 2024
1 parent 983bd0e commit 6d3112c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/backend_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ func (s *S3Backend) Init(key string) error {
var isAws bool
var err error

if s.config.NoDetect {
return nil
}

if !s.config.RegionSet {
err, _ = s.detectBucketLocationByHEAD()
if err == nil {
Expand Down Expand Up @@ -1187,6 +1191,10 @@ func (s *S3Backend) MultipartBlobAbort(param *MultipartBlobCommitInput) (*Multip
}

func (s *S3Backend) MultipartExpire(param *MultipartExpireInput) (*MultipartExpireOutput, error) {
if s.config.NoExpireMultipart {
return &MultipartExpireOutput{}, nil
}

mpu, err := s.ListMultipartUploads(&s3.ListMultipartUploadsInput{
Bucket: &s.bucket,
})
Expand Down
3 changes: 3 additions & 0 deletions internal/cfg/conf_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ type S3Config struct {
ColdMinSize uint64
MultipartAge time.Duration

NoExpireMultipart bool

MultipartCopyThreshold uint64

NoDetect bool
UseSSE bool
UseKMS bool
KMSKeyID string
Expand Down
13 changes: 13 additions & 0 deletions internal/cfg/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ MISC OPTIONS:
Value: "",
},

cli.BoolFlag{
Name: "no-detect",
Usage: "Turn off bucket location and signature algorithm autodetection on start",
},

cli.BoolFlag{
Name: "no-expire-multipart",
Usage: "Do not expire multipart uploads older than --multipart-age on start",
},

cli.StringFlag{
Name: "multipart-age",
Usage: "Multipart uploads older than this value will be deleted on start",
Expand Down Expand Up @@ -947,6 +957,9 @@ func PopulateFlags(c *cli.Context) (ret *FlagStorage) {

config.MultipartCopyThreshold = uint64(c.Int("multipart-copy-threshold")) * 1024 * 1024

config.NoExpireMultipart = c.Bool("no-expire-multipart")
config.NoDetect = c.Bool("no-detect")

config.SDKMaxRetries = c.Int("sdk-max-retries")
config.SDKMinRetryDelay = c.Duration("sdk-min-retry-delay")
config.SDKMaxRetryDelay = c.Duration("sdk-max-retry-delay")
Expand Down

0 comments on commit 6d3112c

Please sign in to comment.