Skip to content

Commit 448436e

Browse files
committed
bugfixes
1 parent 78ebd60 commit 448436e

File tree

12 files changed

+107
-85
lines changed

12 files changed

+107
-85
lines changed

benches/s3/api_benchmarks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ criterion_group!(
8888
//
8989
bench_list_buckets,
9090
bench_object_copy_internal,
91-
//bench_object_append, // TODO: add support to switch on/off s3-express
91+
bench_object_append,
9292
bench_object_put,
9393
//
9494
bench_enable_object_legal_hold,

examples/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub fn create_client_on_play() -> Result<Client, Box<dyn std::error::Error + Sen
2121
Ok(client)
2222
}
2323

24+
#[allow(dead_code)]
2425
pub fn create_client_on_localhost() -> Result<Client, Box<dyn std::error::Error + Send + Sync>> {
2526
let base_url = "http://localhost:9000/".parse::<BaseUrl>()?;
2627
log::info!("Trying to connect to MinIO at: `{:?}`", base_url);

src/s3/builders/copy_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl ToS3Request for UploadPartCopy {
9898
}
9999
if !(1..=10000).contains(&self.part_number) {
100100
return Err(Error::InvalidPartNumber(
101-
"part number must be between 1 and 1000".into(),
101+
"part number must be between 1 and 10000".into(),
102102
));
103103
}
104104
}

src/s3/builders/get_presigned_policy_form_data.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ impl PostPolicy {
104104
}
105105

106106
fn is_reserved_element(element: &str) -> bool {
107-
element == "bucket"
108-
|| element == "x-amz-algorithm"
109-
|| element == "x-amz-credential"
110-
|| element == "x-amz-date"
111-
|| element == "policy"
112-
|| element == "x-amz-signature"
107+
element.eq_ignore_ascii_case("bucket")
108+
|| element.eq_ignore_ascii_case("x-amz-algorithm")
109+
|| element.eq_ignore_ascii_case("x-amz-credential")
110+
|| element.eq_ignore_ascii_case("x-amz-date")
111+
|| element.eq_ignore_ascii_case("policy")
112+
|| element.eq_ignore_ascii_case("x-amz-signature")
113113
}
114114

115115
fn get_credential_string(access_key: &String, date: &UtcTime, region: &String) -> String {
@@ -142,7 +142,10 @@ impl PostPolicy {
142142
}
143143

144144
let v = PostPolicy::trim_dollar(element);
145-
if v == "success_action_redirect" || v == "redirect" || v == "content-length-range" {
145+
if v.eq_ignore_ascii_case("success_action_redirect")
146+
|| v.eq_ignore_ascii_case("redirect")
147+
|| v.eq_ignore_ascii_case("content-length-range")
148+
{
146149
return Err(Error::PostPolicyError(format!(
147150
"{} is unsupported for equals condition",
148151
element
@@ -195,8 +198,8 @@ impl PostPolicy {
195198
}
196199

197200
let v = PostPolicy::trim_dollar(element);
198-
if v == "success_action_status"
199-
|| v == "content-length-range"
201+
if v.eq_ignore_ascii_case("success_action_status")
202+
|| v.eq_ignore_ascii_case("content-length-range")
200203
|| (v.starts_with("x-amz-") && v.starts_with("x-amz-meta-"))
201204
{
202205
return Err(Error::PostPolicyError(format!(

src/s3/builders/put_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ impl ToS3Request for UploadPart {
417417
if let Some(part_number) = self.part_number {
418418
if !(1..=10000).contains(&part_number) {
419419
return Err(Error::InvalidPartNumber(
420-
"part number must be between 1 and 1000".into(),
420+
"part number must be between 1 and 10000".into(),
421421
));
422422
}
423423
}

src/s3/client.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,23 @@ impl Client {
256256
} else {
257257
task::block_in_place(|| match tokio::runtime::Runtime::new() {
258258
Ok(rt) => {
259+
// create a random bucket name, and check if it exists,
260+
// we are not interested in the result, just the headers
261+
// which will contain the server type
262+
259263
let bucket_name: String = rand::thread_rng()
260264
.sample_iter(&Alphanumeric)
261265
.take(20)
262266
.map(char::from)
263267
.collect::<String>()
264268
.to_lowercase();
265269

266-
let express = rt.block_on(async {
270+
let express: bool = rt.block_on(async {
267271
match BucketExists::new(self.clone(), bucket_name).send().await {
268272
Ok(v) => {
269273
if let Some(server) = v.headers.get("server") {
270274
if let Ok(s) = server.to_str() {
271-
return s == "MinIO Enterprise/S3express";
275+
return s.eq_ignore_ascii_case("MinIO Enterprise/S3Express");
272276
}
273277
}
274278
}

src/s3/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub enum ErrorCode {
4444
AccessDenied,
4545
NotSupported,
4646
BucketNotEmpty,
47+
BucketAlreadyOwnedByYou,
4748

4849
OtherError(String),
4950
}
@@ -72,6 +73,8 @@ impl ErrorCode {
7273
"accessdenied" => ErrorCode::AccessDenied,
7374
"notsupported" => ErrorCode::NotSupported,
7475
"bucketnotempty" => ErrorCode::BucketNotEmpty,
76+
"bucketalreadyownedbyyou" => ErrorCode::BucketAlreadyOwnedByYou,
77+
7578
v => ErrorCode::OtherError(v.to_owned()),
7679
}
7780
}
@@ -176,6 +179,7 @@ pub enum Error {
176179
TagDecodingError(String, String),
177180
ContentLengthUnknown,
178181

182+
//TODO are the following still needed?
179183
NoSuchTagSet,
180184
ReplicationConfigurationNotFoundError,
181185
NoSuchObjectLockConfiguration,

src/s3/http.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fn get_aws_info(
171171
}
172172

173173
let mut tokens: Vec<_> = host.get(matcher.len()..).unwrap().split('.').collect();
174-
*dualstack = tokens[0] == "dualstack";
174+
*dualstack = tokens[0].eq_ignore_ascii_case("dualstack");
175175
if *dualstack {
176176
tokens.remove(0);
177177
}
@@ -184,10 +184,12 @@ fn get_aws_info(
184184

185185
let domain_suffix = tokens.join(".");
186186

187-
if host == "s3-external-1.amazonaws.com" {
187+
if host.eq_ignore_ascii_case("s3-external-1.amazonaws.com") {
188188
region_in_host = DEFAULT_REGION.to_string();
189189
}
190-
if host == "s3-us-gov-west-1.amazonaws.com" || host == "s3-fips-us-gov-west-1.amazonaws.com" {
190+
if host.eq_ignore_ascii_case("s3-us-gov-west-1.amazonaws.com")
191+
|| host.eq_ignore_ascii_case("s3-fips-us-gov-west-1.amazonaws.com")
192+
{
191193
region_in_host = "us-gov-west-1".to_string();
192194
}
193195

@@ -336,9 +338,9 @@ impl BaseUrl {
336338
) -> Result<(), Error> {
337339
let mut host = String::from(&self.aws_s3_prefix);
338340
host.push_str(&self.aws_domain_suffix);
339-
if host == "s3-external-1.amazonaws.com"
340-
|| host == "s3-us-gov-west-1.amazonaws.com"
341-
|| host == "s3-fips-us-gov-west-1.amazonaws.com"
341+
if host.eq_ignore_ascii_case("s3-external-1.amazonaws.com")
342+
|| host.eq_ignore_ascii_case("s3-us-gov-west-1.amazonaws.com")
343+
|| host.eq_ignore_ascii_case("s3-fips-us-gov-west-1.amazonaws.com")
342344
{
343345
url.host = host;
344346
return Ok(());
@@ -378,9 +380,9 @@ impl BaseUrl {
378380

379381
let mut host = String::from(&self.aws_s3_prefix);
380382
host.push_str(&self.aws_domain_suffix);
381-
if host == "s3-external-1.amazonaws.com"
382-
|| host == "s3-us-gov-west-1.amazonaws.com"
383-
|| host == "s3-fips-us-gov-west-1.amazonaws.com"
383+
if host.eq_ignore_ascii_case("s3-external-1.amazonaws.com")
384+
|| host.eq_ignore_ascii_case("s3-us-gov-west-1.amazonaws.com")
385+
|| host.eq_ignore_ascii_case("s3-fips-us-gov-west-1.amazonaws.com")
384386
{
385387
url.host = host;
386388
return;

src/s3/response/bucket_exists.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ impl FromS3Response for BucketExistsResponse {
5353
exists: false,
5454
})
5555
}
56-
Err(e) => {
57-
println!("Error: {:?}", e);
58-
Err(e)
59-
}
56+
Err(e) => Err(e),
6057
}
6158
}
6259
}

src/s3/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub enum RetentionMode {
285285

286286
impl RetentionMode {
287287
pub fn parse(s: &str) -> Result<RetentionMode, Error> {
288-
match s {
288+
match s.to_uppercase().as_str() {
289289
"GOVERNANCE" => Ok(RetentionMode::GOVERNANCE),
290290
"COMPLIANCE" => Ok(RetentionMode::COMPLIANCE),
291291
_ => Err(Error::InvalidRetentionMode(s.to_string())),
@@ -407,7 +407,7 @@ pub struct JsonInputSerialization {
407407
}
408408

409409
#[derive(Clone, Debug, Default)]
410-
/// Parque input serialization definitions
410+
/// Parquet input serialization definitions
411411
pub struct ParquetInputSerialization;
412412

413413
#[derive(Clone, Debug, Default)]

0 commit comments

Comments
 (0)