Skip to content

Commit

Permalink
Merge branch 'fix/strict-permissions' of github.com:saalfeldlab/n5-aw…
Browse files Browse the repository at this point in the history
…s-s3 into fix/strict-permissions
  • Loading branch information
bogovicj committed Dec 12, 2024
2 parents 4b78487 + 5c27419 commit 226087f
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,10 @@ public AmazonS3KeyValueAccess(final AmazonS3 s3, final URI containerURI, final b
}

private boolean bucketExists() {
if (bucketCheckedAndExists != null)
return bucketCheckedAndExists;

bucketCheckedAndExists = s3.doesBucketExistV2(bucketName);
return bucketCheckedAndExists;
return bucketCheckedAndExists = bucketCheckedAndExists != null
? bucketCheckedAndExists
: s3.doesBucketExistV2(bucketName);
}

private void createBucket() {
Expand All @@ -156,7 +155,6 @@ private void createBucket() {
if (bucketExists())
return;


Region region;
try {
region = s3.getRegion();
Expand All @@ -172,6 +170,21 @@ private void createBucket() {

}

private void deleteBucket() {
if (!createBucket)
throw new N5Exception("Delete Bucket Not Allowed");

if (!bucketExists())
return;

try {
s3.deleteBucket(bucketName);
bucketCheckedAndExists = false;
} catch (Exception e) {
throw new N5Exception("Could not delete bucket " + bucketName, e);
}
}

@Override
public String[] components(final String path) {

Expand Down Expand Up @@ -516,7 +529,7 @@ public void delete(final String normalPath) {
}
}

s3.deleteBucket(bucketName);
deleteBucket();
return;
}

Expand Down

0 comments on commit 226087f

Please sign in to comment.