Skip to content

Commit

Permalink
#119 - DELETE has a delay in removing file from DynamoDB
Browse files Browse the repository at this point in the history
  • Loading branch information
mfriesen committed Nov 15, 2023
1 parent 1478c41 commit 577fe46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ public ApiRequestHandlerResponse delete(final LambdaLogger logger,
String siteId = authorization.siteId();
String documentId = event.getPathParameters().get("documentId");

logger.log("deleting object " + documentId + " from bucket '" + documentBucket + "'");
if (awsservice.debug()) {
logger.log("deleting object " + documentId + " from bucket '" + documentBucket + "'");
}

DocumentService service = awsservice.getExtension(DocumentService.class);
DocumentItem item = service.findDocument(siteId, documentId);
Expand All @@ -206,12 +208,10 @@ public ApiRequestHandlerResponse delete(final LambdaLogger logger,

if (md.isObjectExists()) {
s3Service.deleteObject(documentBucket, s3Key, null);
}

} else {

if (!service.deleteDocument(siteId, documentId)) {
throw new NotFoundException("Document " + documentId + " not found.");
}
if (!service.deleteDocument(siteId, documentId)) {
throw new NotFoundException("Document " + documentId + " not found.");
}

ApiResponse resp = new ApiMessageResponse("'" + documentId + "' object deleted");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public void testHandleDeleteDocument01() throws Exception {
assertEquals(getHeaders(), "\"headers\":" + GsonUtil.getInstance().toJson(m.get("headers")));

assertFalse(getS3().getObjectMetadata(BUCKET_NAME, s3Key, null).isObjectExists());
assertNull(getDocumentService().findDocument(siteId, documentId));
}
}

Expand Down

0 comments on commit 577fe46

Please sign in to comment.