@@ -63,7 +63,8 @@ async fn function_handler(
6363 let input_pattern =
6464 std:: env:: var ( "INPUT_PATTERN" ) . expect ( "You must define INPUT_PATTERN in the environment" ) ;
6565 let exclude_regex: Option < Regex > = std:: env:: var ( "EXCLUDE_REGEX" )
66- . map ( |ex| Regex :: new ( ex. as_ref ( ) ) . expect ( "Failed to compile EXCLUDE_REGEX" ) ) . ok ( ) ;
66+ . map ( |ex| Regex :: new ( ex. as_ref ( ) ) . expect ( "Failed to compile EXCLUDE_REGEX" ) )
67+ . ok ( ) ;
6768 let output_template = std:: env:: var ( "OUTPUT_TEMPLATE" )
6869 . expect ( "You must define OUTPUT_TEMPLATE in the environment" ) ;
6970
@@ -91,10 +92,11 @@ async fn function_handler(
9192 let output_key = template. render ( & parameters) ?;
9293 info ! ( "Copying {source_key:?} to {output_key:?}" ) ;
9394 if let Some ( bucket) = entity. bucket . name {
94- debug ! ( "Sending a copy request for {bucket} with {source_key} to {output_key}" ) ;
95+ let output_bucket = std:: env:: var ( "OUTPUT_BUCKET" ) . unwrap_or ( bucket. clone ( ) ) ;
96+ debug ! ( "Sending a copy request for {output_bucket} with {bucket}/{source_key} to {output_key}" ) ;
9597 let result = client
9698 . copy_object ( )
97- . bucket ( & bucket )
99+ . bucket ( & output_bucket )
98100 . copy_source ( format ! ( "{bucket}/{source_key}" ) )
99101 . key ( output_key)
100102 . send ( )
@@ -291,16 +293,21 @@ mod tests {
291293
292294 #[ test]
293295 fn test_exclude_regex ( ) {
294- let exclude = Some ( Regex :: new ( r#"^path\/to\/table.*"# ) . expect ( "Failed to compile regular expression" ) ) ;
296+ let exclude = Some (
297+ Regex :: new ( r#"^path\/to\/table.*"# ) . expect ( "Failed to compile regular expression" ) ,
298+ ) ;
295299 let keys = vec ! [
296300 "path/to/alpha" ,
297301 "path/to/bravo/foo.parquet" ,
298302 "path/to/table" ,
299303 "path/to/table/foo.parquet" ,
300304 ] ;
301305
302- let filtered: Vec < _ > = keys. iter ( ) . filter ( |k| !should_exclude ( exclude. as_ref ( ) , k) ) . map ( |k| k. clone ( ) ) . collect ( ) ;
306+ let filtered: Vec < _ > = keys
307+ . iter ( )
308+ . filter ( |k| !should_exclude ( exclude. as_ref ( ) , k) )
309+ . map ( |k| k. clone ( ) )
310+ . collect ( ) ;
303311 assert_ne ! ( filtered, keys) ;
304312 }
305313}
306-
0 commit comments