@@ -31,7 +31,7 @@ async fn main() -> Result<(), anyhow::Error> {
3131 }
3232
3333 debug ! ( "{:?}" , & opt) ;
34- let client = S3Client :: new ( opt. aws_region . clone ( ) . unwrap_or ( Region :: default ( ) ) ) ;
34+ let client = S3Client :: new ( opt. aws_region . clone ( ) . unwrap_or_default ( ) ) ;
3535
3636 let bucket_region: Option < Region > = match client
3737 . get_bucket_location ( GetBucketLocationRequest {
@@ -99,7 +99,7 @@ async fn main() -> Result<(), anyhow::Error> {
9999 . into_iter ( )
100100 . filter ( |x| x. key . is_some ( ) )
101101 . map ( |x| ( x. key . unwrap ( ) , x. storage_class ) )
102- . filter ( |x| x. 0 . chars ( ) . last ( ) . unwrap ( ) != '/' ) ; // Skip "directory" keys - TODO: check issues regarding empty directories
102+ . filter ( |x| ! x. 0 . ends_with ( '/' ) ) ; // Skip "directory" keys - TODO: check issues regarding empty directories
103103
104104 keys_vec. extend ( objects_inner) ;
105105
@@ -149,7 +149,7 @@ async fn main() -> Result<(), anyhow::Error> {
149149
150150 let replace_command = Arc :: new ( replace_command) ;
151151
152- let bucket = Arc :: new ( opt. s3_url . bucket ) ;
152+ let bucket: Arc < str > = Arc :: from ( opt. s3_url . bucket . as_str ( ) ) ;
153153 let canned_acl = Arc :: new ( opt. canned_acl ) ;
154154 for key in keys_vec {
155155 // TODO: Refactor this
@@ -182,9 +182,10 @@ async fn main() -> Result<(), anyhow::Error> {
182182 Ok ( ( ) )
183183}
184184
185+ #[ allow( clippy:: too_many_arguments) ]
185186async fn handle_key (
186187 client : Arc < S3Client > ,
187- bucket : Arc < String > ,
188+ bucket : Arc < str > ,
188189 key : ( String , Option < String > ) ,
189190 replace_command : Arc < ReplaceCommand < ' _ > > ,
190191 dry_run : bool ,
@@ -210,7 +211,7 @@ async fn handle_key(
210211
211212 if !no_preserve_acl && canned_acl. is_none ( ) {
212213 let acl_request = GetObjectAclRequest {
213- bucket : ( * bucket) . clone ( ) ,
214+ bucket : ( * bucket) . to_string ( ) ,
214215 key : key. 0 . clone ( ) ,
215216 request_payer : None ,
216217 version_id : None ,
@@ -262,7 +263,7 @@ async fn handle_key(
262263 let copy_request = match no_preserve_properties {
263264 false => {
264265 let head_request = HeadObjectRequest {
265- bucket : ( * bucket) . clone ( ) ,
266+ bucket : ( * bucket) . to_string ( ) ,
266267 if_match : None ,
267268 if_modified_since : None ,
268269 if_none_match : None ,
@@ -279,7 +280,7 @@ async fn handle_key(
279280 let head_result = client. head_object ( head_request) . await ?;
280281 CopyObjectRequest {
281282 acl : canned_acl. map ( |x| x. to_string ( ) ) ,
282- bucket : ( * bucket) . clone ( ) ,
283+ bucket : ( * bucket) . to_string ( ) ,
283284 cache_control : head_result. cache_control ,
284285 content_disposition : head_result. content_disposition ,
285286 content_encoding : head_result. content_encoding ,
@@ -294,22 +295,22 @@ async fn handle_key(
294295 copy_source_sse_customer_key : None , //TODO
295296 copy_source_sse_customer_key_md5 : head_result. sse_customer_key_md5 . clone ( ) ,
296297 expires : head_result. expires ,
297- grant_full_control : if grant_full_control_vec. len ( ) > 0 {
298+ grant_full_control : if ! grant_full_control_vec. is_empty ( ) {
298299 Some ( grant_full_control_vec. join ( ", " ) )
299300 } else {
300301 None
301302 } ,
302- grant_read : if grant_read_vec. len ( ) > 0 {
303+ grant_read : if ! grant_read_vec. is_empty ( ) {
303304 Some ( grant_read_vec. join ( ", " ) )
304305 } else {
305306 None
306307 } ,
307- grant_read_acp : if grant_read_acp_vec. len ( ) > 0 {
308+ grant_read_acp : if ! grant_read_acp_vec. is_empty ( ) {
308309 Some ( grant_read_acp_vec. join ( ", " ) )
309310 } else {
310311 None
311312 } ,
312- grant_write_acp : if grant_write_acp_vec. len ( ) > 0 {
313+ grant_write_acp : if ! grant_write_acp_vec. is_empty ( ) {
313314 Some ( grant_write_acp_vec. join ( ", " ) )
314315 } else {
315316 None
@@ -336,7 +337,7 @@ async fn handle_key(
336337 }
337338 true => CopyObjectRequest {
338339 acl : canned_acl. map ( |x| x. to_string ( ) ) ,
339- bucket : ( * bucket) . clone ( ) ,
340+ bucket : ( * bucket) . to_string ( ) ,
340341 cache_control : None ,
341342 content_disposition : None ,
342343 content_encoding : None ,
@@ -351,22 +352,22 @@ async fn handle_key(
351352 copy_source_sse_customer_key : None ,
352353 copy_source_sse_customer_key_md5 : None ,
353354 expires : None ,
354- grant_full_control : if grant_full_control_vec. len ( ) > 0 {
355+ grant_full_control : if ! grant_full_control_vec. is_empty ( ) {
355356 Some ( grant_full_control_vec. join ( ", " ) )
356357 } else {
357358 None
358359 } ,
359- grant_read : if grant_read_vec. len ( ) > 0 {
360+ grant_read : if ! grant_read_vec. is_empty ( ) {
360361 Some ( grant_read_vec. join ( ", " ) )
361362 } else {
362363 None
363364 } ,
364- grant_read_acp : if grant_read_acp_vec. len ( ) > 0 {
365+ grant_read_acp : if ! grant_read_acp_vec. is_empty ( ) {
365366 Some ( grant_read_acp_vec. join ( ", " ) )
366367 } else {
367368 None
368369 } ,
369- grant_write_acp : if grant_write_acp_vec. len ( ) > 0 {
370+ grant_write_acp : if ! grant_write_acp_vec. is_empty ( ) {
370371 Some ( grant_write_acp_vec. join ( ", " ) )
371372 } else {
372373 None
0 commit comments