aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api/s3api_bucket_config.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-07-18 00:19:47 -0700
committerchrislu <chris.lu@gmail.com>2025-07-18 00:19:47 -0700
commit7bec2ef94b303f36912f58816ca6295ed2d69cfe (patch)
tree625d87a340468f3a090117bd6a978a53018dc4c2 /weed/s3api/s3api_bucket_config.go
parentf9cbed7ee1a59c1345466b80e254a656352cc143 (diff)
downloadseaweedfs-7bec2ef94b303f36912f58816ca6295ed2d69cfe.tar.xz
seaweedfs-7bec2ef94b303f36912f58816ca6295ed2d69cfe.zip
cache and use bucket object lock config
Diffstat (limited to 'weed/s3api/s3api_bucket_config.go')
-rw-r--r--weed/s3api/s3api_bucket_config.go42
1 files changed, 34 insertions, 8 deletions
diff --git a/weed/s3api/s3api_bucket_config.go b/weed/s3api/s3api_bucket_config.go
index 43c056973..05abf3863 100644
--- a/weed/s3api/s3api_bucket_config.go
+++ b/weed/s3api/s3api_bucket_config.go
@@ -2,6 +2,7 @@ package s3api
import (
"encoding/json"
+ "encoding/xml"
"fmt"
"path/filepath"
"strings"
@@ -17,14 +18,15 @@ import (
// BucketConfig represents cached bucket configuration
type BucketConfig struct {
- Name string
- Versioning string // "Enabled", "Suspended", or ""
- Ownership string
- ACL []byte
- Owner string
- CORS *cors.CORSConfiguration
- LastModified time.Time
- Entry *filer_pb.Entry
+ Name string
+ Versioning string // "Enabled", "Suspended", or ""
+ Ownership string
+ ACL []byte
+ Owner string
+ CORS *cors.CORSConfiguration
+ ObjectLockConfig *ObjectLockConfiguration // Cached parsed Object Lock configuration
+ LastModified time.Time
+ Entry *filer_pb.Entry
}
// BucketConfigCache provides caching for bucket configurations
@@ -121,6 +123,16 @@ func (s3a *S3ApiServer) getBucketConfig(bucket string) (*BucketConfig, s3err.Err
if owner, exists := bucketEntry.Extended[s3_constants.ExtAmzOwnerKey]; exists {
config.Owner = string(owner)
}
+ // Parse Object Lock configuration if present
+ if objectLockConfigXML, exists := bucketEntry.Extended[s3_constants.ExtObjectLockConfigKey]; exists {
+ var objectLockConfig ObjectLockConfiguration
+ if err := xml.Unmarshal(objectLockConfigXML, &objectLockConfig); err != nil {
+ glog.Errorf("getBucketConfig: failed to parse Object Lock configuration for bucket %s: %v", bucket, err)
+ } else {
+ config.ObjectLockConfig = &objectLockConfig
+ glog.V(2).Infof("getBucketConfig: cached Object Lock configuration for bucket %s", bucket)
+ }
+ }
}
// Load CORS configuration from .s3metadata
@@ -173,6 +185,20 @@ func (s3a *S3ApiServer) updateBucketConfig(bucket string, updateFn func(*BucketC
if config.Owner != "" {
config.Entry.Extended[s3_constants.ExtAmzOwnerKey] = []byte(config.Owner)
}
+ // Update Object Lock configuration in extended attributes
+ if config.ObjectLockConfig != nil {
+ configXML, err := xml.Marshal(config.ObjectLockConfig)
+ if err != nil {
+ glog.Errorf("updateBucketConfig: failed to marshal Object Lock configuration for bucket %s: %v", bucket, err)
+ return s3err.ErrInternalError
+ }
+ config.Entry.Extended[s3_constants.ExtObjectLockConfigKey] = configXML
+
+ // Also set the boolean flag for backward compatibility
+ if config.ObjectLockConfig.ObjectLockEnabled != "" {
+ config.Entry.Extended[s3_constants.ExtObjectLockEnabledKey] = []byte(config.ObjectLockConfig.ObjectLockEnabled)
+ }
+ }
// Save to filer
err := s3a.updateEntry(s3a.option.BucketsPath, config.Entry)