Skip to content

Commit

Permalink
fix(storage): disable soft delete policy using 0 retentionDurationSec…
Browse files Browse the repository at this point in the history
…onds (#11226)
  • Loading branch information
frankyn authored Dec 5, 2024
1 parent 002f45c commit f087721
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions storage/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1341,8 +1341,10 @@ func (ua *BucketAttrsToUpdate) toRawBucket() *raw.Bucket {
}
if ua.SoftDeletePolicy != nil {
if ua.SoftDeletePolicy.RetentionDuration == 0 {
rb.NullFields = append(rb.NullFields, "SoftDeletePolicy")
rb.SoftDeletePolicy = nil
rb.SoftDeletePolicy = &raw.BucketSoftDeletePolicy{
RetentionDurationSeconds: 0,
ForceSendFields: []string{"RetentionDurationSeconds"},
}
} else {
rb.SoftDeletePolicy = ua.SoftDeletePolicy.toRawSoftDeletePolicy()
}
Expand Down
5 changes: 4 additions & 1 deletion storage/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,10 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) {
}
got = au3.toRawBucket()
want = &raw.Bucket{
NullFields: []string{"RetentionPolicy", "Encryption", "Logging", "Website", "SoftDeletePolicy"},
NullFields: []string{"RetentionPolicy", "Encryption", "Logging", "Website"},
SoftDeletePolicy: &raw.BucketSoftDeletePolicy{
ForceSendFields: []string{"RetentionDurationSeconds"},
},
}
if msg := testutil.Diff(got, want); msg != "" {
t.Error(msg)
Expand Down

0 comments on commit f087721

Please sign in to comment.