mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-07-26 07:58:14 +00:00
chore: remove various useless code
- call expect directly on Result lint message: called `ok().expect()` on a `Result` value help: you can call `expect()` directly on the `Result` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#ok_expect - use assign operation instead of manual implementation lint message: manual implementation of an assign operation help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#assign_op_pattern - remove useless call to format lint message: useless use of `format!` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#useless_format - remove useless `?Sized` lint message: `?Sized` bound is ignored because of a `Sized` requirement note: ...because `Deserialize` has the bound `Sized` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#needless_maybe_sized - use is_some instead of pattern maching with Some(_) lint message: redundant pattern matching, consider using `is_some()` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#redundant_pattern_matching - remove unneeded unit return type lint message: unneeded unit return type help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#unused_unit - remove redundant closure lint message: redundant closure help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#redundant_closure - use derive Default instead of manual implementation lint message: this `impl` can be derived help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#derivable_impls - remove unneeded `return` statement help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#needless_return - remove empty string from println call lint message: empty string literal in `println!` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#println_empty_string - remove clone() on type than implement Copy lint message: using `clone` on type `Option<ChecksumValue>` which implements the `Copy` trait help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#clone_on_copy - remove useless let binding lint message: this let-binding has unit value help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#let_unit_value - remove useless len comparison to zero, already test of empty lint message: length comparison to zero help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#len_zero - remove useless `as_deref` call lint message: derefed type is same as origin help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#needless_option_as_deref - remove useless conversion of the same type lint message: useless conversion to the same type: `replication_mode::ReplicationFactor` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#useless_conversion - remove useless bool_comparison lint message: equality checks against false can be replaced by a negation help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#bool_comparison - remove useless to_string lint message: unnecessary use of `to_string` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#unnecessary_to_owned Signed-off-by: Gwen Lg <me@gwenlg.fr>
This commit is contained in:
@@ -183,7 +183,7 @@ impl RequestHandler for CreateBucketRequest {
|
||||
|
||||
let key = helper.key().get_existing_key(&la.access_key_id).await?;
|
||||
let state = key.state.as_option().unwrap();
|
||||
if matches!(state.local_aliases.get(&la.alias), Some(_)) {
|
||||
if state.local_aliases.get(&la.alias).is_some() {
|
||||
return Err(Error::bad_request("Local alias already exists"));
|
||||
}
|
||||
}
|
||||
|
||||
+49
-49
@@ -19,7 +19,7 @@ use crate::api::*;
|
||||
(status = 200, description = "Garage daemon metrics exported in Prometheus format"),
|
||||
),
|
||||
)]
|
||||
fn Metrics() -> () {}
|
||||
fn Metrics() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/health",
|
||||
@@ -36,7 +36,7 @@ as long as it is able to have a quorum of nodes for read and write operations.
|
||||
(status = 503, description = "This Garage daemon is not able to handle requests")
|
||||
),
|
||||
)]
|
||||
fn Health() -> () {}
|
||||
fn Health() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/check",
|
||||
@@ -54,7 +54,7 @@ do not correspond to an actual website.
|
||||
(status = 400, description = "No static website bucket exists for this domain")
|
||||
),
|
||||
)]
|
||||
fn CheckDomain() -> () {}
|
||||
fn CheckDomain() {}
|
||||
|
||||
// **********************************************
|
||||
// Cluster operations
|
||||
@@ -78,7 +78,7 @@ Returns the cluster's current status, including:
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetClusterStatus() -> () {}
|
||||
fn GetClusterStatus() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/v2/GetClusterHealth",
|
||||
@@ -88,7 +88,7 @@ fn GetClusterStatus() -> () {}
|
||||
(status = 200, description = "Cluster health report", body = GetClusterHealthResponse),
|
||||
),
|
||||
)]
|
||||
fn GetClusterHealth() -> () {}
|
||||
fn GetClusterHealth() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/v2/GetClusterStatistics",
|
||||
@@ -103,7 +103,7 @@ Fetch global cluster statistics.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetClusterStatistics() -> () {}
|
||||
fn GetClusterStatistics() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/ConnectClusterNodes",
|
||||
@@ -115,7 +115,7 @@ fn GetClusterStatistics() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn ConnectClusterNodes() -> () {}
|
||||
fn ConnectClusterNodes() {}
|
||||
|
||||
// **********************************************
|
||||
// Admin API token operations
|
||||
@@ -130,7 +130,7 @@ fn ConnectClusterNodes() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn ListAdminTokens() -> () {}
|
||||
fn ListAdminTokens() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/v2/GetAdminTokenInfo",
|
||||
@@ -145,7 +145,7 @@ You can search by specifying the exact token identifier (`id`) or by specifying
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetAdminTokenInfo() -> () {}
|
||||
fn GetAdminTokenInfo() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/CreateAdminToken",
|
||||
@@ -157,7 +157,7 @@ fn GetAdminTokenInfo() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn CreateAdminToken() -> () {}
|
||||
fn CreateAdminToken() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/UpdateAdminToken",
|
||||
@@ -172,7 +172,7 @@ Updates information about the specified admin API token.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn UpdateAdminToken() -> () {}
|
||||
fn UpdateAdminToken() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/DeleteAdminToken",
|
||||
@@ -184,7 +184,7 @@ fn UpdateAdminToken() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn DeleteAdminToken() -> () {}
|
||||
fn DeleteAdminToken() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/v2/GetCurrentAdminTokenInfo",
|
||||
@@ -197,7 +197,7 @@ Return information about the calling admin API token.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetCurrentAdminTokenInfo() -> () {}
|
||||
fn GetCurrentAdminTokenInfo() {}
|
||||
|
||||
// **********************************************
|
||||
// Layout operations
|
||||
@@ -219,7 +219,7 @@ Returns the cluster's current layout, including:
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetClusterLayout() -> () {}
|
||||
fn GetClusterLayout() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/v2/GetClusterLayoutHistory",
|
||||
@@ -232,7 +232,7 @@ Returns the history of layouts in the cluster
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetClusterLayoutHistory() -> () {}
|
||||
fn GetClusterLayoutHistory() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/UpdateClusterLayout",
|
||||
@@ -261,7 +261,7 @@ Contrary to the CLI that may update only a subset of the fields capacity, zone a
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn UpdateClusterLayout() -> () {}
|
||||
fn UpdateClusterLayout() {}
|
||||
|
||||
// Hack: we cannot use the UpdateClusterLayoutRequest from api.rs,
|
||||
// as it contains (via NodeRoleChange) an untagged enum flattenned into
|
||||
@@ -315,7 +315,7 @@ Computes a new layout taking into account the staged parameters, and returns it
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn PreviewClusterLayoutChanges() -> () {}
|
||||
fn PreviewClusterLayoutChanges() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/ApplyClusterLayout",
|
||||
@@ -331,7 +331,7 @@ Applies to the cluster the layout changes currently registered as staged layout
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn ApplyClusterLayout() -> () {}
|
||||
fn ApplyClusterLayout() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/RevertClusterLayout",
|
||||
@@ -342,7 +342,7 @@ fn ApplyClusterLayout() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn RevertClusterLayout() -> () {}
|
||||
fn RevertClusterLayout() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/ClusterLayoutSkipDeadNodes",
|
||||
@@ -354,7 +354,7 @@ fn RevertClusterLayout() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn ClusterLayoutSkipDeadNodes() -> () {}
|
||||
fn ClusterLayoutSkipDeadNodes() {}
|
||||
|
||||
// **********************************************
|
||||
// Access key operations
|
||||
@@ -369,7 +369,7 @@ fn ClusterLayoutSkipDeadNodes() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn ListKeys() -> () {}
|
||||
fn ListKeys() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/v2/GetKeyInfo",
|
||||
@@ -386,7 +386,7 @@ For confidentiality reasons, the secret key is not returned by default: you must
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetKeyInfo() -> () {}
|
||||
fn GetKeyInfo() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/CreateKey",
|
||||
@@ -398,7 +398,7 @@ fn GetKeyInfo() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn CreateKey() -> () {}
|
||||
fn CreateKey() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/ImportKey",
|
||||
@@ -414,7 +414,7 @@ Imports an existing API key. This feature must only be used for migrations and b
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn ImportKey() -> () {}
|
||||
fn ImportKey() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/UpdateKey",
|
||||
@@ -431,7 +431,7 @@ Updates information about the specified API access key.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn UpdateKey() -> () {}
|
||||
fn UpdateKey() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/DeleteKey",
|
||||
@@ -443,7 +443,7 @@ fn UpdateKey() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn DeleteKey() -> () {}
|
||||
fn DeleteKey() {}
|
||||
|
||||
// **********************************************
|
||||
// Bucket operations
|
||||
@@ -458,7 +458,7 @@ fn DeleteKey() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn ListBuckets() -> () {}
|
||||
fn ListBuckets() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/v2/GetBucketInfo",
|
||||
@@ -475,7 +475,7 @@ and its quotas (if any).
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetBucketInfo() -> () {}
|
||||
fn GetBucketInfo() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/CreateBucket",
|
||||
@@ -490,7 +490,7 @@ Technically, you can also specify both `globalAlias` and `localAlias` and that w
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn CreateBucket() -> () {}
|
||||
fn CreateBucket() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/UpdateBucket",
|
||||
@@ -516,7 +516,7 @@ to change only one of the two quotas.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn UpdateBucket() -> () {}
|
||||
fn UpdateBucket() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/DeleteBucket",
|
||||
@@ -534,7 +534,7 @@ Deletes a storage bucket. A bucket cannot be deleted if it is not empty.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn DeleteBucket() -> () {}
|
||||
fn DeleteBucket() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/CleanupIncompleteUploads",
|
||||
@@ -546,7 +546,7 @@ fn DeleteBucket() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn CleanupIncompleteUploads() -> () {}
|
||||
fn CleanupIncompleteUploads() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/v2/InspectObject",
|
||||
@@ -568,7 +568,7 @@ upload is in progress and not yet finished.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn InspectObject() -> () {}
|
||||
fn InspectObject() {}
|
||||
|
||||
// **********************************************
|
||||
// Operations on permissions for keys on buckets
|
||||
@@ -594,7 +594,7 @@ If you want to disallow read for the key, check the DenyBucketKey operation.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn AllowBucketKey() -> () {}
|
||||
fn AllowBucketKey() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/DenyBucketKey",
|
||||
@@ -616,7 +616,7 @@ If you want the key to have the reading permission, check the AllowBucketKey ope
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn DenyBucketKey() -> () {}
|
||||
fn DenyBucketKey() {}
|
||||
|
||||
// **********************************************
|
||||
// Operations on bucket aliases
|
||||
@@ -632,7 +632,7 @@ fn DenyBucketKey() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn AddBucketAlias() -> () {}
|
||||
fn AddBucketAlias() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/RemoveBucketAlias",
|
||||
@@ -644,7 +644,7 @@ fn AddBucketAlias() -> () {}
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn RemoveBucketAlias() -> () {}
|
||||
fn RemoveBucketAlias() {}
|
||||
|
||||
// Hack for issue #1249 (see UpdateClusterLayout)
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
|
||||
@@ -680,7 +680,7 @@ Return information about the Garage daemon running on one or several nodes.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetNodeInfo() -> () {}
|
||||
fn GetNodeInfo() {}
|
||||
|
||||
#[utoipa::path(get,
|
||||
path = "/v2/GetNodeStatistics",
|
||||
@@ -696,7 +696,7 @@ Fetch statistics for one or several Garage nodes.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetNodeStatistics() -> () {}
|
||||
fn GetNodeStatistics() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/CreateMetadataSnapshot",
|
||||
@@ -710,7 +710,7 @@ Instruct one or several nodes to take a snapshot of their metadata databases.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn CreateMetadataSnapshot() -> () {}
|
||||
fn CreateMetadataSnapshot() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/LaunchRepairOperation",
|
||||
@@ -725,7 +725,7 @@ Launch a repair operation on one or several cluster nodes.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn LaunchRepairOperation() -> () {}
|
||||
fn LaunchRepairOperation() {}
|
||||
|
||||
// **********************************************
|
||||
// Worker operations
|
||||
@@ -744,7 +744,7 @@ List background workers currently running on one or several cluster nodes.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn ListWorkers() -> () {}
|
||||
fn ListWorkers() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/GetWorkerInfo",
|
||||
@@ -759,7 +759,7 @@ Get information about the specified background worker on one or several cluster
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetWorkerInfo() -> () {}
|
||||
fn GetWorkerInfo() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/GetWorkerVariable",
|
||||
@@ -774,7 +774,7 @@ Fetch values of one or several worker variables, from one or several cluster nod
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetWorkerVariable() -> () {}
|
||||
fn GetWorkerVariable() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/SetWorkerVariable",
|
||||
@@ -789,7 +789,7 @@ Set the value for a worker variable, on one or several cluster nodes.
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn SetWorkerVariable() -> () {}
|
||||
fn SetWorkerVariable() {}
|
||||
|
||||
// **********************************************
|
||||
// Block operations
|
||||
@@ -807,7 +807,7 @@ List data blocks that are currently in an errored state on one or several Garage
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn ListBlockErrors() -> () {}
|
||||
fn ListBlockErrors() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/GetBlockInfo",
|
||||
@@ -822,7 +822,7 @@ Get detailed information about a data block stored on a Garage node, including a
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn GetBlockInfo() -> () {}
|
||||
fn GetBlockInfo() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/RetryBlockResync",
|
||||
@@ -837,7 +837,7 @@ Instruct Garage node(s) to retry the resynchronization of one or several missing
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn RetryBlockResync() -> () {}
|
||||
fn RetryBlockResync() {}
|
||||
|
||||
#[utoipa::path(post,
|
||||
path = "/v2/PurgeBlocks",
|
||||
@@ -854,7 +854,7 @@ This will remove all objects and in-progress multipart uploads that contain the
|
||||
(status = 500, description = "Internal server error")
|
||||
),
|
||||
)]
|
||||
fn PurgeBlocks() -> () {}
|
||||
fn PurgeBlocks() {}
|
||||
|
||||
// **********************************************
|
||||
// **********************************************
|
||||
|
||||
@@ -345,7 +345,7 @@ impl BlockRcRepair {
|
||||
#[async_trait]
|
||||
impl Worker for BlockRcRepair {
|
||||
fn name(&self) -> String {
|
||||
format!("Block refcount repair worker")
|
||||
"Block refcount repair worker".into()
|
||||
}
|
||||
|
||||
fn status(&self) -> WorkerStatus {
|
||||
|
||||
@@ -154,7 +154,7 @@ impl<A: ApiHandler> ApiServer<A> {
|
||||
{
|
||||
format!("{forwarded_for_ip_addr} (via {addr})")
|
||||
} else {
|
||||
format!("{addr}")
|
||||
addr
|
||||
};
|
||||
// we only do this to log the access key, so we can discard any error
|
||||
let key = self
|
||||
|
||||
@@ -505,15 +505,15 @@ mod tests {
|
||||
let mut conditions = policy_2.into_conditions().unwrap();
|
||||
|
||||
assert_eq!(
|
||||
conditions.params.remove(&"acl".to_string()),
|
||||
conditions.params.remove("acl"),
|
||||
Some(vec![Operation::Equal("public-read".into())])
|
||||
);
|
||||
assert_eq!(
|
||||
conditions.params.remove(&"bucket".to_string()),
|
||||
conditions.params.remove("bucket"),
|
||||
Some(vec![Operation::Equal("johnsmith".into())])
|
||||
);
|
||||
assert_eq!(
|
||||
conditions.params.remove(&"key".to_string()),
|
||||
conditions.params.remove("key"),
|
||||
Some(vec![Operation::StartsWith("user/eric/".into())])
|
||||
);
|
||||
assert!(conditions.params.is_empty());
|
||||
@@ -536,7 +536,7 @@ mod tests {
|
||||
let mut conditions = policy_2.into_conditions().unwrap();
|
||||
|
||||
assert_eq!(
|
||||
conditions.params.remove(&"acl".to_string()),
|
||||
conditions.params.remove("acl"),
|
||||
Some(vec![Operation::Equal("public-read".into())])
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -544,9 +544,7 @@ mod tests {
|
||||
vec![Operation::StartsWith("image/".into())]
|
||||
);
|
||||
assert_eq!(
|
||||
conditions
|
||||
.params
|
||||
.remove(&"success_action_redirect".to_string()),
|
||||
conditions.params.remove("success_action_redirect"),
|
||||
Some(vec![Operation::StartsWith("".into())])
|
||||
);
|
||||
assert!(conditions.params.is_empty());
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ impl DataBlock {
|
||||
return DataBlock::compressed(data_compressed.into());
|
||||
}
|
||||
}
|
||||
DataBlock::plain(data.into())
|
||||
DataBlock::plain(data)
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
|
||||
+2
-2
@@ -325,7 +325,7 @@ fn make_data_dirs(dirs: &DataDirEnum) -> Result<Vec<DataDir>, Error> {
|
||||
let mut ok = false;
|
||||
for dir in dirs.iter() {
|
||||
let state = match &dir.capacity {
|
||||
Some(cap) if dir.read_only == false => {
|
||||
Some(cap) if !dir.read_only => {
|
||||
let capacity = cap.parse::<bytesize::ByteSize>()
|
||||
.ok_or_message("invalid capacity value")?.as_u64();
|
||||
if capacity == 0 {
|
||||
@@ -336,7 +336,7 @@ fn make_data_dirs(dirs: &DataDirEnum) -> Result<Vec<DataDir>, Error> {
|
||||
capacity,
|
||||
}
|
||||
}
|
||||
None if dir.read_only == true => {
|
||||
None if dir.read_only => {
|
||||
DataDirState::ReadOnly
|
||||
}
|
||||
_ => return Err(Error::Message(format!("data directories in data_dir should have a capacity value or be marked read_only, not the case for {}", dir.path.to_string_lossy()))),
|
||||
|
||||
@@ -569,12 +569,10 @@ impl BlockManager {
|
||||
async {
|
||||
match self.find_block(hash).await {
|
||||
Some(p) => self.read_block_from(hash, &p).await,
|
||||
None => {
|
||||
return Err(Error::Message(format!(
|
||||
"block {:?} not found on node",
|
||||
hash
|
||||
)));
|
||||
}
|
||||
None => Err(Error::Message(format!(
|
||||
"block {:?} not found on node",
|
||||
hash
|
||||
))),
|
||||
}
|
||||
}
|
||||
.bound_record_duration(&self.metrics.block_read_duration)
|
||||
|
||||
+1
-1
@@ -558,7 +558,7 @@ impl Worker for RebalanceWorker {
|
||||
}
|
||||
|
||||
fn status(&self) -> WorkerStatus {
|
||||
let t_cur = self.t_finished.unwrap_or_else(|| now_msec());
|
||||
let t_cur = self.t_finished.unwrap_or_else(now_msec);
|
||||
let rate = self.moved_bytes / std::cmp::max(1, (t_cur - self.t_started) / 1000);
|
||||
let mut freeform = vec![
|
||||
format!("Blocks moved: {}", self.moved),
|
||||
|
||||
@@ -45,16 +45,14 @@ pub(crate) fn open_db(path: &PathBuf, opt: &OpenOpt) -> Result<Db> {
|
||||
}
|
||||
}
|
||||
match env_builder.open(path) {
|
||||
Err(heed::Error::Io(e)) if e.kind() == std::io::ErrorKind::OutOfMemory => {
|
||||
return Err(Error(
|
||||
"OutOfMemory error while trying to open LMDB database. This can happen \
|
||||
Err(heed::Error::Io(e)) if e.kind() == std::io::ErrorKind::OutOfMemory => Err(Error(
|
||||
"OutOfMemory error while trying to open LMDB database. This can happen \
|
||||
if your operating system is not allowing you to use sufficient virtual \
|
||||
memory address space. Please check that no limit is set (ulimit -v). \
|
||||
You may also try to set a smaller `lmdb_map_size` configuration parameter. \
|
||||
On 32-bit machines, you should probably switch to another database engine."
|
||||
.into(),
|
||||
))
|
||||
}
|
||||
.into(),
|
||||
)),
|
||||
Err(e) => Err(Error(format!("Cannot open LMDB database: {}", e).into())),
|
||||
Ok(db) => Ok(LmdbDb::init(db)),
|
||||
}
|
||||
|
||||
+1
-10
@@ -68,22 +68,13 @@ impl std::str::FromStr for Engine {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct OpenOpt {
|
||||
pub fsync: bool,
|
||||
pub lmdb_map_size: Option<usize>,
|
||||
pub fjall_block_cache_size: Option<usize>,
|
||||
}
|
||||
|
||||
impl Default for OpenOpt {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
fsync: false,
|
||||
lmdb_map_size: None,
|
||||
fjall_block_cache_size: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open_db(path: &PathBuf, engine: Engine, opt: &OpenOpt) -> Result<Db> {
|
||||
match engine {
|
||||
// ---- Sqlite DB ----
|
||||
|
||||
@@ -308,7 +308,7 @@ impl IDb for SqliteDb {
|
||||
|
||||
trace!("transaction done");
|
||||
drop(lock);
|
||||
return res;
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -567,7 +567,7 @@ fn print_bucket_info(bucket: &GetBucketInfoResponse) {
|
||||
|
||||
format_table(info);
|
||||
|
||||
println!("");
|
||||
println!();
|
||||
println!("==== KEYS FOR THIS BUCKET ====");
|
||||
let mut key_info = vec!["Permissions\tAccess key\t\tLocal aliases".to_string()];
|
||||
key_info.extend(bucket.keys.iter().map(|key| {
|
||||
|
||||
@@ -296,7 +296,7 @@ fn print_key_info(key: &GetKeyInfoResponse) {
|
||||
]);
|
||||
format_table(table);
|
||||
|
||||
println!("");
|
||||
println!();
|
||||
println!("==== BUCKETS FOR THIS KEY ====");
|
||||
let mut bucket_info = vec!["Permissions\tID\tGlobal aliases\tLocal aliases".to_string()];
|
||||
bucket_info.extend(key.buckets.iter().map(|bucket| {
|
||||
|
||||
@@ -649,13 +649,13 @@ struct PollRangeResponse {
|
||||
impl<'a> Filter<'a> {
|
||||
fn query_params(&self) -> Vec<(&'static str, std::borrow::Cow<'_, str>)> {
|
||||
let mut res = Vec::<(&'static str, std::borrow::Cow<str>)>::with_capacity(8);
|
||||
if let Some(start) = self.start.as_deref() {
|
||||
if let Some(start) = self.start {
|
||||
res.push(("start", start.into()));
|
||||
}
|
||||
if let Some(end) = self.end.as_deref() {
|
||||
if let Some(end) = self.end {
|
||||
res.push(("end", end.into()));
|
||||
}
|
||||
if let Some(prefix) = self.prefix.as_deref() {
|
||||
if let Some(prefix) = self.prefix {
|
||||
res.push(("prefix", prefix.into()));
|
||||
}
|
||||
if let Some(limit) = &self.limit {
|
||||
|
||||
@@ -160,8 +160,8 @@ impl Crdt for MpuPart {
|
||||
(x, _) => x,
|
||||
};
|
||||
self.checksum = match (self.checksum.take(), &other.checksum) {
|
||||
(None, Some(_)) => other.checksum.clone(),
|
||||
(Some(x), Some(y)) if x < *y => other.checksum.clone(),
|
||||
(None, Some(_)) => other.checksum,
|
||||
(Some(x), Some(y)) if x < *y => other.checksum,
|
||||
(x, _) => x,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ impl BytesBuf {
|
||||
/// Return the content as a stream of individual chunks
|
||||
pub fn into_stream(self) -> ByteStream {
|
||||
use futures::stream::StreamExt;
|
||||
Box::pin(futures::stream::iter(self.buf).map(|x| Ok(x)))
|
||||
Box::pin(futures::stream::iter(self.buf).map(Ok))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,6 @@ mod test {
|
||||
#[test]
|
||||
fn test_bytes_buf() {
|
||||
let mut buf = BytesBuf::new();
|
||||
assert!(buf.len() == 0);
|
||||
assert!(buf.is_empty());
|
||||
|
||||
buf.extend(Bytes::from(b"Hello, world!".to_vec()));
|
||||
@@ -176,7 +175,6 @@ mod test {
|
||||
buf.take_all(),
|
||||
Bytes::from(b"Hello, world!1234567890".to_vec())
|
||||
);
|
||||
assert!(buf.len() == 0);
|
||||
assert!(buf.is_empty());
|
||||
|
||||
buf.extend(Bytes::from(b"1234567890".to_vec()));
|
||||
@@ -193,7 +191,6 @@ mod test {
|
||||
buf.take_exact(11),
|
||||
Some(Bytes::from(b"llo, world!".to_vec()))
|
||||
);
|
||||
assert!(buf.len() == 0);
|
||||
assert!(buf.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ pub(crate) trait RecvLoop: Sync + 'static {
|
||||
|
||||
if size == CANCEL_REQUEST {
|
||||
if let Some(mut stream) = streams.remove(&id) {
|
||||
let _ = stream.send(Err(std::io::Error::new(
|
||||
stream.send(Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"netapp: cancel requested",
|
||||
)));
|
||||
@@ -135,7 +135,7 @@ pub(crate) trait RecvLoop: Sync + 'static {
|
||||
// If we cannot put packet in channel, it means that the
|
||||
// receiving end of the channel is disconnected.
|
||||
// We still need to reach eos before dropping this sender
|
||||
let _ = sender.send(packet);
|
||||
sender.send(packet);
|
||||
}
|
||||
|
||||
if has_cont {
|
||||
|
||||
@@ -355,7 +355,7 @@ impl Graph<WeightedEdge> {
|
||||
|
||||
// Remark that the cycle in prev is in the reverse order compared to the cycle
|
||||
// in the graph. Thus the .rev().
|
||||
return cycles_prev
|
||||
cycles_prev
|
||||
.iter()
|
||||
.map(|cycle| {
|
||||
cycle
|
||||
@@ -364,7 +364,7 @@ impl Graph<WeightedEdge> {
|
||||
.map(|id| self.id_to_vertex[*id])
|
||||
.collect()
|
||||
})
|
||||
.collect();
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::replication_mode::*;
|
||||
|
||||
impl LayoutHistory {
|
||||
pub fn new(replication_factor: ReplicationFactor) -> Self {
|
||||
let version = LayoutVersion::new(replication_factor.into());
|
||||
let version = LayoutVersion::new(replication_factor);
|
||||
|
||||
let staging = LayoutStaging {
|
||||
parameters: Lww::<LayoutParameters>::new(version.parameters),
|
||||
|
||||
@@ -77,7 +77,7 @@ fn check_against_naive(cl: &LayoutVersion) -> Result<bool, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(false);
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn show_msg(msg: &Message) {
|
||||
|
||||
@@ -68,7 +68,6 @@ impl BackgroundRunner {
|
||||
{
|
||||
self.send_worker
|
||||
.send(Box::new(worker))
|
||||
.ok()
|
||||
.expect("Could not put worker in queue");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -90,11 +90,11 @@ impl FixedBytes32 {
|
||||
if *byte == u8::MAX {
|
||||
*byte = 0;
|
||||
} else {
|
||||
*byte = *byte + 1;
|
||||
*byte += 1;
|
||||
return Some(ret);
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ where
|
||||
/// data formats)
|
||||
pub fn nonversioned_decode<T>(bytes: &[u8]) -> Result<T, rmp_serde::decode::Error>
|
||||
where
|
||||
T: for<'de> Deserialize<'de> + ?Sized,
|
||||
T: for<'de> Deserialize<'de>,
|
||||
{
|
||||
rmp_serde::decode::from_slice::<_>(bytes)
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ impl WebServer {
|
||||
.span_builder(format!("Web {} request", req.method()))
|
||||
.with_trace_id(gen_trace_id())
|
||||
.with_attributes(vec![
|
||||
KeyValue::new("host", format!("{}", host_header.clone())),
|
||||
KeyValue::new("method", format!("{}", req.method())),
|
||||
KeyValue::new("host", host_header.clone()),
|
||||
KeyValue::new("method", req.method().to_string()),
|
||||
KeyValue::new("uri", req.uri().to_string()),
|
||||
])
|
||||
.start(&tracer);
|
||||
|
||||
Reference in New Issue
Block a user