refactor: rework bucket value get, relateted to or_func_call

this avoid bucket_website_config value compute if not needed
This commit is contained in:
Gwen Lg
2026-01-28 11:07:46 +01:00
committed by Alex
parent bbb62dfa85
commit f6414210fa
+9 -2
View File
@@ -295,13 +295,20 @@ impl Cli {
)); ));
} }
// Destructure becket info to allow separate use of `id` and `website_config`
let GetBucketInfoResponse {
id: bucket_id,
website_config: bucket_website_config,
..
} = bucket;
let wa = if opt.allow { let wa = if opt.allow {
UpdateBucketWebsiteAccess { UpdateBucketWebsiteAccess {
enabled: true, enabled: true,
index_document: Some(opt.index_document.clone()), index_document: Some(opt.index_document.clone()),
error_document: opt error_document: opt
.error_document .error_document
.or(bucket.website_config.and_then(|x| x.error_document.clone())), .or_else(|| bucket_website_config.and_then(|x| x.error_document.clone())),
} }
} else { } else {
UpdateBucketWebsiteAccess { UpdateBucketWebsiteAccess {
@@ -313,7 +320,7 @@ impl Cli {
let res = self let res = self
.api_request(UpdateBucketRequest { .api_request(UpdateBucketRequest {
id: bucket.id, id: bucket_id,
body: UpdateBucketRequestBody { body: UpdateBucketRequestBody {
website_access: Some(wa), website_access: Some(wa),
quotas: None, quotas: None,