Skip to content

Commit

Permalink
fix fix
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwittig committed Aug 13, 2019
1 parent a7ec0f5 commit ee310f6
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions test/src/test/java/de/widdix/awscftemplates/AAWSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,25 @@ protected final void deleteObject(final String bucketName, final String key) {
}
}

private void emptyBucket(final String name) {
ObjectListing objectListing = s3.listObjects(name);
while (true) {
objectListing.getObjectSummaries().forEach((summary) -> s3.deleteObject(name, summary.getKey()));
if (objectListing.isTruncated()) {
objectListing = s3.listNextBatchOfObjects(objectListing);
} else {
break;
protected final void emptyBucket(final String name) {
if (Config.get(Config.Key.DELETION_POLICY).equals("delete")) {
ObjectListing objectListing = s3.listObjects(name);
while (true) {
objectListing.getObjectSummaries().forEach((summary) -> s3.deleteObject(name, summary.getKey()));
if (objectListing.isTruncated()) {
objectListing = s3.listNextBatchOfObjects(objectListing);
} else {
break;
}
}
}
VersionListing versionListing = s3.listVersions(new ListVersionsRequest().withBucketName(name));
while (true) {
versionListing.getVersionSummaries().forEach((vs) -> s3.deleteVersion(name, vs.getKey(), vs.getVersionId()));
if (versionListing.isTruncated()) {
versionListing = s3.listNextBatchOfVersions(versionListing);
} else {
break;
VersionListing versionListing = s3.listVersions(new ListVersionsRequest().withBucketName(name));
while (true) {
versionListing.getVersionSummaries().forEach((vs) -> s3.deleteVersion(name, vs.getKey(), vs.getVersionId()));
if (versionListing.isTruncated()) {
versionListing = s3.listNextBatchOfVersions(versionListing);
} else {
break;
}
}
}
}
Expand Down

0 comments on commit ee310f6

Please sign in to comment.