rishabhdaim commented on code in PR #2558:
URL: https://github.com/apache/jackrabbit-oak/pull/2558#discussion_r2416482353


##########
oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java:
##########
@@ -624,29 +633,13 @@ public void deleteAllMetadataRecords(String prefix) {
 
         ClassLoader contextClassLoader = 
Thread.currentThread().getContextClassLoader();
         try {
-            Thread.currentThread().setContextClassLoader(
-                getClass().getClassLoader());
+            
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
 
-            ListObjectsRequest listObjectsRequest =
-                new 
ListObjectsRequest().withBucketName(bucket).withPrefix(addMetaKeyPrefix(prefix));
-            ObjectListing metaList = s3service.listObjects(listObjectsRequest);
-            List<DeleteObjectsRequest.KeyVersion> deleteList = new 
ArrayList<DeleteObjectsRequest.KeyVersion>();
-            List<String> keysToDelete = new ArrayList<>();
-            for (S3ObjectSummary s3ObjSumm : metaList.getObjectSummaries()) {
-                deleteList.add(new 
DeleteObjectsRequest.KeyVersion(s3ObjSumm.getKey()));
-                keysToDelete.add(s3ObjSumm.getKey());
-            }
-            if (!deleteList.isEmpty()) {
-                RemoteStorageMode mode = (RemoteStorageMode) 
properties.getOrDefault(S3Constants.MODE, RemoteStorageMode.S3);
-                if (mode == RemoteStorageMode.S3) {
-                    DeleteObjectsRequest delObjsReq = new 
DeleteObjectsRequest(bucket);
-                    delObjsReq.setKeys(deleteList);
-                    s3service.deleteObjects(delObjsReq);
-                } else {
-                    // GCP does not support bulk delete operations, hence we 
need to delete each object individually
-                    keysToDelete.forEach(key -> s3service.deleteObject(bucket, 
key));
-                }
-            }
+            ListObjectsV2Iterable metaList = 
s3Client.listObjectsV2Paginator(builder -> builder
+                    .bucket(bucket)
+                    .prefix(addMetaKeyPrefix(prefix))
+                    .build());
+            Utils.deleteBucketObjects(bucket, properties, s3Client, metaList);

Review Comment:
   Same reason, had to avoid duplicate code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to