Skip to content

Commit

Permalink
Add diagnostic logging for TrinoS3FileSystem delete
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Aug 7, 2023
1 parent add7f07 commit 4ccd023
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ private static boolean isDirectoryMediaType(String contentType)
return MediaType.parse(contentType).is(DIRECTORY_MEDIA_TYPE);
}
catch (IllegalArgumentException e) {
log.debug(e, "isDirectoryMediaType: failed to inspect contentType [%s], assuming not a directory", contentType);
return false;
}
}
Expand Down Expand Up @@ -652,6 +653,7 @@ public boolean rename(Path src, Path dst)
delete(src, true);
}

// TODO should we return true also when deleteObject() returned false?
return true;
}

Expand Down Expand Up @@ -695,6 +697,7 @@ else if (deletePrefixResult == DeletePrefixResult.DELETE_KEYS_FAILURE) {
}
deleteObject(key + DIRECTORY_SUFFIX);
}
// TODO should we return true also when deleteObject() returned false? (currently deleteObject's return value is never used)
return true;
}

Expand Down Expand Up @@ -744,8 +747,9 @@ private boolean directory(Path path)

private boolean deleteObject(String key)
{
String bucketName = getBucketName(uri);
try {
DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(getBucketName(uri), key);
DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(bucketName, key);
if (requesterPaysEnabled) {
// TODO use deleteObjectRequest.setRequesterPays() when https://github.com/aws/aws-sdk-java/issues/1219 is fixed
// currently the method exists, but is ineffective (doesn't set the required HTTP header)
Expand All @@ -756,6 +760,8 @@ private boolean deleteObject(String key)
return true;
}
catch (AmazonClientException e) {
// TODO should we propagate this?
log.debug(e, "Failed to delete object from the bucket %s: %s", bucketName, key);
return false;
}
}
Expand Down

0 comments on commit 4ccd023

Please sign in to comment.