From e5dabbe45d2ec3520b30d62c9763b089ecaf5562 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 16 Feb 2023 21:15:19 -0500 Subject: [PATCH] boto3: list_versions() omits empty KeyMarker/VersionIdMarker Signed-off-by: Casey Bodley (cherry picked from commit a536dd0e88ac908cde07bf312c8db6fe4a0c9b69) --- s3tests_boto3/functional/__init__.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/s3tests_boto3/functional/__init__.py b/s3tests_boto3/functional/__init__.py index 22b136c..a65b54c 100644 --- a/s3tests_boto3/functional/__init__.py +++ b/s3tests_boto3/functional/__init__.py @@ -82,18 +82,13 @@ def get_objects_list(bucket, client=None, prefix=None): # generator function that returns object listings in batches, where each # batch is a list of dicts compatible with delete_objects() def list_versions(client, bucket, batch_size): - key_marker = '' - version_marker = '' + kwargs = {'Bucket': bucket, 'MaxKeys': batch_size} truncated = True while truncated: - listing = client.list_object_versions( - Bucket=bucket, - KeyMarker=key_marker, - VersionIdMarker=version_marker, - MaxKeys=batch_size) + listing = client.list_object_versions(**kwargs) - key_marker = listing.get('NextKeyMarker') - version_marker = listing.get('NextVersionIdMarker') + kwargs['KeyMarker'] = listing.get('NextKeyMarker') + kwargs['VersionIdMarker'] = listing.get('NextVersionIdMarker') truncated = listing['IsTruncated'] objs = listing.get('Versions', []) + listing.get('DeleteMarkers', [])