style: collapse nested if block

lint message: this `if` statement can be collapsed
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#collapsible_if
This commit is contained in:
Gwen Lg
2025-12-14 12:57:29 +01:00
parent 8772db8228
commit a426b00e87
3 changed files with 21 additions and 13 deletions
+4 -2
View File
@@ -343,14 +343,16 @@ impl RequestHandler for ClusterLayoutSkipDeadNodesRequest {
for node in all_nodes.iter() {
// Update ACK tracker for dead nodes or for all nodes if --allow-missing-data
if self.allow_missing_data || !status.iter().any(|x| x.id == *node && x.is_up) {
if layout.update_trackers.ack_map.set_max(*node, self.version) {
let ack_changed = layout.update_trackers.ack_map.set_max(*node, self.version);
if ack_changed {
ack_updated.push(hex::encode(node));
}
}
// If --allow-missing-data, update SYNC tracker for all nodes.
if self.allow_missing_data {
if layout.update_trackers.sync_map.set_max(*node, self.version) {
let sync_changed = layout.update_trackers.sync_map.set_max(*node, self.version);
if sync_changed {
sync_updated.push(hex::encode(node));
}
}
+13 -9
View File
@@ -269,20 +269,24 @@ fn verify_signed_headers(headers: &HeaderMap, signed_headers: &[HeaderName]) ->
return Err(Error::bad_request("Header `Host` should be signed"));
}
for (name, _) in headers.iter() {
// Enforce signature of all x-amz-* headers, except x-amz-content-sh256
// because it is included in the canonical request in all cases
if name.as_str().starts_with("x-amz-") && name != X_AMZ_CONTENT_SHA256 {
if !signed_headers.contains(name) {
return Err(Error::bad_request(format!(
"Header `{}` should be signed",
name
)));
}
// Enforce signature of some headers
if header_should_be_signed(name) && !signed_headers.contains(name) {
return Err(Error::bad_request(format!(
"Header `{}` should be signed",
name
)));
}
}
Ok(())
}
// Indicates whether a header is required to be signed
fn header_should_be_signed(name: &HeaderName) -> bool {
// Enforce signature of all x-amz-* headers, except x-amz-content-sh256
// because it is included in the canonical request in all cases
name.as_str().starts_with("x-amz-") && name != X_AMZ_CONTENT_SHA256
}
pub fn string_to_sign(datetime: &DateTime<Utc>, scope_string: &str, canonical_req: &str) -> String {
let mut hasher = Sha256::default();
hasher.update(canonical_req.as_bytes());