kopia lustrzana https://github.com/gaul/s3proxy
Handle non-empty delete container in azureblob-sdk
Found via s3-tests. References #606.pull/702/head
rodzic
ff8e12e631
commit
8ebf6ce84e
|
@ -226,6 +226,26 @@ public final class AzureBlobStore extends BaseBlobStore {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteContainerIfEmpty(String container) {
|
||||
var client = blobServiceClient.getBlobContainerClient(container);
|
||||
try {
|
||||
var page = client.listBlobsByHierarchy(
|
||||
/*delimiter=*/ null, /*options=*/ null, /*timeout=*/ null)
|
||||
.iterableByPage().iterator().next();
|
||||
if (!page.getValue().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
blobServiceClient.deleteBlobContainer(container);
|
||||
return true;
|
||||
} catch (BlobStorageException bse) {
|
||||
if (bse.getErrorCode() == BlobErrorCode.CONTAINER_NOT_FOUND) {
|
||||
return true;
|
||||
}
|
||||
throw bse;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blobExists(String container, String key) {
|
||||
var client = blobServiceClient.getBlobContainerClient(container)
|
||||
|
|
Ładowanie…
Reference in New Issue