Skip to content

Commit

Permalink
Use marker when calling list_objects
Browse files Browse the repository at this point in the history
Previously test_bucket_list_delimiter_not_skip_special failed in
nuke_buckets due to not deleting all the keys.
  • Loading branch information
gaul committed Jul 18, 2020
1 parent 24cdcab commit f5d5faf
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions s3tests_boto3/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,28 @@ def get_objects_list(bucket, client=None, prefix=None):
if client == None:
client = get_client()

if prefix == None:
response = client.list_objects(Bucket=bucket)
else:
response = client.list_objects(Bucket=bucket, Prefix=prefix)
objects_list = []

if 'Contents' in response:
contents = response['Contents']
for obj in contents:
objects_list.append(obj['Key'])
marker = None
while True:
if prefix == None:
if marker == None:
response = client.list_objects(Bucket=bucket)
else:
response = client.list_objects(Bucket=bucket, Marker=marker)
else:
if marker == None:
response = client.list_objects(Bucket=bucket, Prefix=prefix)
else:
response = client.list_objects(Bucket=bucket, Prefix=prefix, Marker=marker)

if 'Contents' in response:
contents = response['Contents']
for obj in contents:
objects_list.append(obj['Key'])

marker = response.get('NextMarker')
if marker == None:
break

return objects_list

Expand Down

0 comments on commit f5d5faf

Please sign in to comment.