Skip to content

Commit

Permalink
perf: Fix get_s3_last_mdoified_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
na4da committed Dec 24, 2021
1 parent 668f59e commit 23328bf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugins/modules/aws_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,13 @@ def get_etag(s3, bucket, obj, version=None):


def get_s3_last_modified_timestamp(s3, bucket, obj, version=None):
s3_head_object = s3.head_object(Bucket=bucket, Key=obj, VersionId=version)
return s3_head_object['LastModified'].timestamp()
if version:
key_check = s3.head_object(Bucket=bucket, Key=obj, VersionId=version)
else:
key_check = s3.head_object(Bucket=bucket, Key=obj)
if not key_check:
return None
return key_check['LastModified'].timestamp()


def is_local_object_latest(module, s3, bucket, obj, version=None, local_file=None):
Expand Down

0 comments on commit 23328bf

Please sign in to comment.