@@ -63,7 +63,8 @@ async fn function_handler(
63
63
let input_pattern =
64
64
std:: env:: var ( "INPUT_PATTERN" ) . expect ( "You must define INPUT_PATTERN in the environment" ) ;
65
65
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 ( ) ;
67
68
let output_template = std:: env:: var ( "OUTPUT_TEMPLATE" )
68
69
. expect ( "You must define OUTPUT_TEMPLATE in the environment" ) ;
69
70
@@ -91,10 +92,11 @@ async fn function_handler(
91
92
let output_key = template. render ( & parameters) ?;
92
93
info ! ( "Copying {source_key:?} to {output_key:?}" ) ;
93
94
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}" ) ;
95
97
let result = client
96
98
. copy_object ( )
97
- . bucket ( & bucket )
99
+ . bucket ( & output_bucket )
98
100
. copy_source ( format ! ( "{bucket}/{source_key}" ) )
99
101
. key ( output_key)
100
102
. send ( )
@@ -291,16 +293,21 @@ mod tests {
291
293
292
294
#[ test]
293
295
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
+ ) ;
295
299
let keys = vec ! [
296
300
"path/to/alpha" ,
297
301
"path/to/bravo/foo.parquet" ,
298
302
"path/to/table" ,
299
303
"path/to/table/foo.parquet" ,
300
304
] ;
301
305
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 ( ) ;
303
311
assert_ne ! ( filtered, keys) ;
304
312
}
305
313
}
306
-
0 commit comments