1515from common .aws_s3_utils import (
1616 copy_file_to_external_bucket ,
1717 delete_file ,
18- is_file_in_bucket ,
1918 move_file ,
2019)
2120from common .clients import STREAM_NAME , get_s3_client , logger
@@ -64,8 +63,6 @@ def handle_record(record) -> dict:
6463 "error" : str (error ),
6564 }
6665
67- expiry_timestamp = "unknown"
68-
6966 if bucket_name != SOURCE_BUCKET_NAME :
7067 return handle_unexpected_bucket_name (bucket_name , file_key )
7168
@@ -77,10 +74,6 @@ def handle_record(record) -> dict:
7774 message = "Processing not required. Event was for a file moved to /archive or /processing"
7875 return {"statusCode" : 200 , "message" : message , "file_key" : file_key }
7976
80- # Set default values for file-specific variables
81- message_id = "Message id was not created"
82- created_at_formatted_string = "created_at_time not identified"
83-
8477 message_id = str (uuid4 ())
8578 s3_response = get_s3_client ().get_object (Bucket = bucket_name , Key = file_key )
8679 created_at_formatted_string , expiry_timestamp = get_creation_and_expiry_times (s3_response )
@@ -256,13 +249,6 @@ def handle_extended_attributes_file(
256249 Returns a dictionary containing information to be included in the logs.
257250 """
258251
259- # here: the sequence of events should be
260- # 1. upsert 'processing'
261- # 2. move the file to the dest bucket
262- # 3. check the file is present in the dest bucket
263- # 4. if it is, delete it from the src bucket, upsert 'processed'
264- # 5. if it isn't, move it to the archive/ folder, upsert 'failed'
265- # NB for this to work we have to retool upsert so it accepts overwrites, i.e. ignore the ConditionExpression
266252 extended_attribute_identifier = None
267253 try :
268254 organization_code = validate_extended_attributes_file_key (file_key )
@@ -277,6 +263,7 @@ def handle_extended_attributes_file(
277263 FileStatus .PROCESSING ,
278264 )
279265
266+ # TODO: agree the prefix with DPS
280267 dest_file_key = f"dps_destination/{ file_key } "
281268 copy_file_to_external_bucket (
282269 bucket_name ,
@@ -286,7 +273,6 @@ def handle_extended_attributes_file(
286273 EXPECTED_BUCKET_OWNER_ACCOUNT ,
287274 EXPECTED_BUCKET_OWNER_ACCOUNT ,
288275 )
289- is_file_in_bucket (DPS_DESTINATION_BUCKET_NAME , dest_file_key )
290276 delete_file (bucket_name , dest_file_key , EXPECTED_BUCKET_OWNER_ACCOUNT )
291277
292278 upsert_audit_table (
@@ -306,7 +292,6 @@ def handle_extended_attributes_file(
306292 "queue_name" : extended_attribute_identifier ,
307293 }
308294 except ( # pylint: disable=broad-exception-caught
309- ClientError ,
310295 VaccineTypePermissionsError ,
311296 InvalidFileKeyError ,
312297 UnhandledAuditTableError ,
0 commit comments