forked from TrueCloudLab/s3-tests
boto3: list_versions() omits empty KeyMarker/VersionIdMarker
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit a536dd0e88
)
This commit is contained in:
parent
f060572730
commit
e5dabbe45d
1 changed files with 4 additions and 9 deletions
|
@ -82,18 +82,13 @@ def get_objects_list(bucket, client=None, prefix=None):
|
||||||
# generator function that returns object listings in batches, where each
|
# generator function that returns object listings in batches, where each
|
||||||
# batch is a list of dicts compatible with delete_objects()
|
# batch is a list of dicts compatible with delete_objects()
|
||||||
def list_versions(client, bucket, batch_size):
|
def list_versions(client, bucket, batch_size):
|
||||||
key_marker = ''
|
kwargs = {'Bucket': bucket, 'MaxKeys': batch_size}
|
||||||
version_marker = ''
|
|
||||||
truncated = True
|
truncated = True
|
||||||
while truncated:
|
while truncated:
|
||||||
listing = client.list_object_versions(
|
listing = client.list_object_versions(**kwargs)
|
||||||
Bucket=bucket,
|
|
||||||
KeyMarker=key_marker,
|
|
||||||
VersionIdMarker=version_marker,
|
|
||||||
MaxKeys=batch_size)
|
|
||||||
|
|
||||||
key_marker = listing.get('NextKeyMarker')
|
kwargs['KeyMarker'] = listing.get('NextKeyMarker')
|
||||||
version_marker = listing.get('NextVersionIdMarker')
|
kwargs['VersionIdMarker'] = listing.get('NextVersionIdMarker')
|
||||||
truncated = listing['IsTruncated']
|
truncated = listing['IsTruncated']
|
||||||
|
|
||||||
objs = listing.get('Versions', []) + listing.get('DeleteMarkers', [])
|
objs = listing.get('Versions', []) + listing.get('DeleteMarkers', [])
|
||||||
|
|
Loading…
Reference in a new issue