Skip to content

Commit 8c38810

Browse files
fix: revert partially padok-team#588
Signed-off-by: Michael Todorovic <[email protected]>
1 parent 3321cda commit 8c38810

File tree

1 file changed

+6
-45
lines changed
  • internal/datastore/storage/s3

1 file changed

+6
-45
lines changed

internal/datastore/storage/s3/s3.go

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ import (
1818

1919
// Implements Storage interface using AWS S3
2020
type S3 struct {
21-
Client *storage.Client
22-
Config config.S3Config
23-
supportsChecksumSha256 bool
21+
Client *storage.Client
22+
Config config.S3Config
2423
}
2524

2625
// New creates a new AWS S3 client
@@ -32,16 +31,11 @@ func New(config config.S3Config) *S3 {
3231
client := storage.NewFromConfig(sdkConfig, func(o *storage.Options) {
3332
o.UsePathStyle = config.UsePathStyle
3433
})
35-
s3Client := &S3{
36-
Config: config,
37-
Client: client,
38-
supportsChecksumSha256: false,
39-
}
40-
41-
// Check for checksum support during initialization
42-
s3Client.IsChecksumSha256Supported()
4334

44-
return s3Client
35+
return &S3{
36+
Config: config,
37+
Client: client,
38+
}
4539
}
4640

4741
func (a *S3) Get(key string) ([]byte, error) {
@@ -110,10 +104,6 @@ func (a *S3) Set(key string, data []byte, ttl int) error {
110104
Body: bytes.NewReader(data),
111105
}
112106

113-
if a.supportsChecksumSha256 {
114-
input.ChecksumAlgorithm = types.ChecksumAlgorithmSha256
115-
}
116-
117107
_, err := a.Client.PutObject(context.TODO(), input)
118108
if err != nil {
119109
return err
@@ -162,32 +152,3 @@ func (a *S3) List(prefix string) ([]string, error) {
162152

163153
return keys, nil
164154
}
165-
166-
func (a *S3) IsChecksumSha256Supported() bool {
167-
// Create a test input with SHA256 checksum algorithm
168-
testInput := &storage.PutObjectInput{
169-
Bucket: &a.Config.Bucket,
170-
Key: aws.String("_test_checksum_support"),
171-
Body: bytes.NewReader([]byte("test")),
172-
ChecksumAlgorithm: types.ChecksumAlgorithmSha256,
173-
}
174-
175-
// Try to put an object with checksum algorithm
176-
_, err := a.Client.PutObject(context.TODO(), testInput)
177-
178-
// Clean up the test object regardless of the result
179-
// Ignore any error from deletion as it's just a cleanup operation
180-
deleteInput := &storage.DeleteObjectInput{
181-
Bucket: &a.Config.Bucket,
182-
Key: aws.String("_test_checksum_support"),
183-
}
184-
a.Client.DeleteObject(context.TODO(), deleteInput)
185-
186-
if err != nil {
187-
a.supportsChecksumSha256 = false
188-
return false
189-
}
190-
191-
a.supportsChecksumSha256 = true
192-
return true
193-
}

0 commit comments

Comments
 (0)