optimize(infra): remove tautological condition (#856)

This commit is contained in:
Shawfix 2025-08-22 15:00:24 +08:00 committed by GitHub
parent 59c1d9aa03
commit f09c624988
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 12 deletions

View File

@ -138,21 +138,17 @@ func (t *s3Client) CheckAndCreateBucket(ctx context.Context) error {
return nil // already exist
}
if err != nil {
// bucket not exist
if awsErr, ok := err.(interface{ ErrorCode() string }); ok && awsErr.ErrorCode() == "404" {
input := &s3.CreateBucketInput{
Bucket: aws.String(bucket),
}
// create bucket
_, err := client.CreateBucket(ctx, input)
return err
}
// other case
awsErr, ok := err.(interface{ ErrorCode() string })
if !ok || awsErr.ErrorCode() != "404" {
return err
}
return nil
// bucket not exist
input := &s3.CreateBucketInput{
Bucket: aws.String(bucket),
}
_, err = client.CreateBucket(ctx, input)
return err
}
func (t *s3Client) PutObject(ctx context.Context, objectKey string, content []byte, opts ...storage.PutOptFn) error {