mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-07 05:13:12 +00:00
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:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -163,7 +163,8 @@ impl LayoutManager {
|
||||
let prev_layout_check = layout.is_check_ok();
|
||||
|
||||
if !prev_layout_check || adv.check().is_ok() {
|
||||
if layout.update(|l| l.merge(adv)) {
|
||||
let changed = layout.update(|l| l.merge(adv));
|
||||
if changed {
|
||||
layout.update_update_trackers(self.node_id);
|
||||
if prev_layout_check && !layout.is_check_ok() {
|
||||
panic!("Merged two correct layouts and got an incorrect layout.");
|
||||
@@ -181,7 +182,8 @@ impl LayoutManager {
|
||||
let prev_digest = layout.digest();
|
||||
|
||||
if layout.inner().update_trackers != *adv {
|
||||
if layout.update(|l| l.update_trackers.merge(adv)) {
|
||||
let changed = layout.update(|l| l.update_trackers.merge(adv));
|
||||
if changed {
|
||||
layout.update_update_trackers(self.node_id);
|
||||
assert!(layout.digest() != prev_digest);
|
||||
return Some(layout.inner().update_trackers.clone());
|
||||
|
||||
Reference in New Issue
Block a user