SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
s3: keep an unset CORS MaxAgeSeconds unset (#12272)
Jay Hemnani26783fbcb375
diff --git a/weed/s3api/s3api_bucket_config.go b/weed/s3api/s3api_bucket_config.goindex 6040a589bf..254b2adb83 100644--- a/weed/s3api/s3api_bucket_config.go+++ b/weed/s3api/s3api_bucket_config.go@@ -860,10 +860,10 @@ func corsConfigFromProto(protoConfig *s3_pb.CORSConfiguration) *cors.CORSConfigu}}-// getMaxAgeSecondsValue safely extracts max age seconds value+// getMaxAgeSecondsValue safely extracts max age seconds value; -1 stores an unset MaxAgeSecondsfunc getMaxAgeSecondsValue(maxAge *int) int {if maxAge == nil {- return 0+ return -1}return *maxAge}diff --git a/weed/s3api/s3api_bucket_cors_proto_test.go b/weed/s3api/s3api_bucket_cors_proto_test.gonew file mode 100644index 0000000000..30742049bf--- /dev/null+++ b/weed/s3api/s3api_bucket_cors_proto_test.go@@ -0,0 +1,22 @@+package s3api++import (+ "testing"++ "github.com/seaweedfs/seaweedfs/weed/s3api/cors"+)++func TestCorsRuleProtoRoundTripMaxAge(t *testing.T) {+ unset := corsRuleFromProto(corsRuleToProto(cors.CORSRule{AllowedMethods: []string{"GET"}, AllowedOrigins: []string{"*"}}))+ if unset.MaxAgeSeconds != nil {+ t.Errorf("unset MaxAgeSeconds came back as %d", *unset.MaxAgeSeconds)+ }++ for _, age := range []int{0, 3000} {+ age := age+ got := corsRuleFromProto(corsRuleToProto(cors.CORSRule{AllowedMethods: []string{"GET"}, AllowedOrigins: []string{"*"}, MaxAgeSeconds: &age}))+ if got.MaxAgeSeconds == nil || *got.MaxAgeSeconds != age {+ t.Errorf("MaxAgeSeconds %d came back as %v", age, got.MaxAgeSeconds)+ }+ }+}