Skip to content

Commit

Permalink
Handle missing container in more places
Browse files Browse the repository at this point in the history
References #606.
  • Loading branch information
gaul committed Nov 10, 2024
1 parent b02ce67 commit 5272c79
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/main/java/org/gaul/s3proxy/azureblob/AzureBlobStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,12 @@ public Blob getBlob(String container, String key, GetOptions options) {
try {
blobStream = client.openInputStream(azureRange, conditions);
} catch (BlobStorageException bse) {
if (bse.getErrorCode() == BlobErrorCode.BLOB_NOT_FOUND) {
var code = bse.getErrorCode();
if (code == BlobErrorCode.BLOB_NOT_FOUND) {
throw new KeyNotFoundException(container, key, "");
} else if (bse.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET) {
} else if (code == BlobErrorCode.CONTAINER_NOT_FOUND) {
throw new ContainerNotFoundException(container, "");
} else if (code == BlobErrorCode.CONDITION_NOT_MET) {
var request = HttpRequest.builder()
.method("GET")
.endpoint(endpoint)
Expand Down Expand Up @@ -547,10 +550,17 @@ protected boolean deleteAndVerifyContainerGone(String container) {
@Override
public ContainerAccess getContainerAccess(String container) {
var client = blobServiceClient.getBlobContainerClient(container);
return client.getAccessPolicy().getBlobAccessType() ==
PublicAccessType.CONTAINER ?
ContainerAccess.PUBLIC_READ :
ContainerAccess.PRIVATE;
try {
return client.getAccessPolicy().getBlobAccessType() ==
PublicAccessType.CONTAINER ?
ContainerAccess.PUBLIC_READ :
ContainerAccess.PRIVATE;
} catch (BlobStorageException bse) {
if (bse.getErrorCode() == BlobErrorCode.CONTAINER_NOT_FOUND) {
throw new ContainerNotFoundException(container, "");
}
throw bse;
}
}

@Override
Expand Down

0 comments on commit 5272c79

Please sign in to comment.