Skip to content

Commit 1243a19

Browse files
committed
cargo clippy
1 parent 564bc9a commit 1243a19

File tree

7 files changed

+189
-203
lines changed

7 files changed

+189
-203
lines changed

src/s3/builders/copy_object.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -969,16 +969,16 @@ impl ComposeSource {
969969
}
970970

971971
pub fn build_headers(&mut self, object_size: u64, etag: String) -> Result<(), ValidationErr> {
972-
if let Some(v) = self.offset {
973-
if v >= object_size {
974-
return Err(ValidationErr::InvalidComposeSourceOffset {
975-
bucket: self.bucket.to_string(),
976-
object: self.object.to_string(),
977-
version: self.version_id.clone(),
978-
offset: v,
979-
object_size,
980-
});
981-
}
972+
if let Some(v) = self.offset
973+
&& v >= object_size
974+
{
975+
return Err(ValidationErr::InvalidComposeSourceOffset {
976+
bucket: self.bucket.to_string(),
977+
object: self.object.to_string(),
978+
version: self.version_id.clone(),
979+
offset: v,
980+
object_size,
981+
});
982982
}
983983

984984
if let Some(v) = self.length {

src/s3/builders/put_object.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -414,19 +414,19 @@ impl ToS3Request for UploadPart {
414414
check_bucket_name(&self.bucket, true)?;
415415
check_object_name(&self.object)?;
416416

417-
if let Some(upload_id) = &self.upload_id {
418-
if upload_id.is_empty() {
419-
return Err(ValidationErr::InvalidUploadId(
420-
"upload ID cannot be empty".into(),
421-
));
422-
}
417+
if let Some(upload_id) = &self.upload_id
418+
&& upload_id.is_empty()
419+
{
420+
return Err(ValidationErr::InvalidUploadId(
421+
"upload ID cannot be empty".into(),
422+
));
423423
}
424-
if let Some(part_number) = self.part_number {
425-
if !(1..=MAX_MULTIPART_COUNT).contains(&part_number) {
426-
return Err(ValidationErr::InvalidPartNumber(format!(
427-
"part number must be between 1 and {MAX_MULTIPART_COUNT}"
428-
)));
429-
}
424+
if let Some(part_number) = self.part_number
425+
&& !(1..=MAX_MULTIPART_COUNT).contains(&part_number)
426+
{
427+
return Err(ValidationErr::InvalidPartNumber(format!(
428+
"part number must be between 1 and {MAX_MULTIPART_COUNT}"
429+
)));
430430
}
431431
}
432432

@@ -948,10 +948,10 @@ pub fn calc_part_info(
948948
}
949949
}
950950

951-
if let Size::Known(v) = object_size {
952-
if v > MAX_OBJECT_SIZE {
953-
return Err(ValidationErr::InvalidObjectSize(v));
954-
}
951+
if let Size::Known(v) = object_size
952+
&& v > MAX_OBJECT_SIZE
953+
{
954+
return Err(ValidationErr::InvalidObjectSize(v));
955955
}
956956

957957
match (object_size, part_size) {

src/s3/client.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,11 @@ impl Client {
540540
)?;
541541

542542
// If the error is a NoSuchBucket or RetryHead, remove the bucket from the region map.
543-
if matches!(e.code(), MinioErrorCode::NoSuchBucket)
544-
|| matches!(e.code(), MinioErrorCode::RetryHead)
543+
if (matches!(e.code(), MinioErrorCode::NoSuchBucket)
544+
|| matches!(e.code(), MinioErrorCode::RetryHead))
545+
&& let Some(v) = bucket_name
545546
{
546-
if let Some(v) = bucket_name {
547-
self.shared.region_map.remove(v);
548-
}
547+
self.shared.region_map.remove(v);
549548
};
550549

551550
Err(Error::S3Server(S3ServerError::S3Error(Box::new(e))))
@@ -637,13 +636,14 @@ impl SharedClientItems {
637636
message.push_str(region);
638637
}
639638

640-
if retry && !region.is_empty() && (method == Method::HEAD) {
641-
if let Some(v) = bucket_name {
642-
if self.region_map.contains_key(v) {
643-
code = MinioErrorCode::RetryHead;
644-
message = String::new();
645-
}
646-
}
639+
if retry
640+
&& !region.is_empty()
641+
&& (method == Method::HEAD)
642+
&& let Some(v) = bucket_name
643+
&& self.region_map.contains_key(v)
644+
{
645+
code = MinioErrorCode::RetryHead;
646+
message = String::new();
647647
}
648648

649649
Ok((code, message))

0 commit comments

Comments
 (0)