From ee310f613bcc219145ac4de72f6d2a4e42b35c84 Mon Sep 17 00:00:00 2001 From: Michael Wittig Date: Tue, 13 Aug 2019 19:27:30 +0200 Subject: [PATCH] fix fix --- .../de/widdix/awscftemplates/AAWSTest.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/test/src/test/java/de/widdix/awscftemplates/AAWSTest.java b/test/src/test/java/de/widdix/awscftemplates/AAWSTest.java index 08d02700b..82d1817cf 100644 --- a/test/src/test/java/de/widdix/awscftemplates/AAWSTest.java +++ b/test/src/test/java/de/widdix/awscftemplates/AAWSTest.java @@ -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; + } } } }