@@ -306,11 +306,6 @@ public BlobContainer blobContainer(BlobPath path) {
306306    private  static  class  DeletionExceptions  {
307307        Exception  exception  = null ;
308308        private  int  count  = 0 ;
309-         final  boolean  ignoreNoSuchKey ;
310- 
311-         DeletionExceptions (boolean  ignoreNoSuchKey ) {
312-             this .ignoreNoSuchKey  = ignoreNoSuchKey ;
313-         }
314309
315310        void  useOrMaybeSuppress (Exception  e ) {
316311            if  (count  < MAX_DELETE_EXCEPTIONS ) {
@@ -320,15 +315,15 @@ void useOrMaybeSuppress(Exception e) {
320315        }
321316    }
322317
323-     void  deleteBlobs (OperationPurpose  purpose , boolean   ignoreNoSuchKey ,  Iterator <String > blobNames ) throws  IOException  {
318+     void  deleteBlobs (OperationPurpose  purpose , Iterator <String > blobNames ) throws  IOException  {
324319        if  (blobNames .hasNext () == false ) {
325320            return ;
326321        }
327322
328323        final  List <ObjectIdentifier > partition  = new  ArrayList <>();
329324        try  {
330325            // S3 API only allows 1k blobs per delete so we split up the given blobs into requests of max. 1k deletes 
331-             final  var  deletionExceptions  = new  DeletionExceptions (ignoreNoSuchKey );
326+             final  var  deletionExceptions  = new  DeletionExceptions ();
332327            blobNames .forEachRemaining (key  -> {
333328                partition .add (ObjectIdentifier .builder ().key (key ).build ());
334329                if  (partition .size () == bulkDeletionBatchSize ) {
@@ -360,7 +355,7 @@ private void deletePartition(OperationPurpose purpose, List<ObjectIdentifier> pa
360355        while  (true ) {
361356            try  (AmazonS3Reference  clientReference  = clientReference ()) {
362357                final  var  response  = clientReference .client ().deleteObjects (bulkDelete (purpose , this , partition ));
363-                 if  (maybeRecordDeleteErrors (response , deletionExceptions ) == false ) {
358+                 if  (maybeRecordDeleteErrors (purpose ,  response , deletionExceptions ) == false ) {
364359                    s3RepositoriesMetrics .retryDeletesHistogram ().record (retryCounter );
365360                }
366361                return ;
@@ -384,7 +379,11 @@ private void deletePartition(OperationPurpose purpose, List<ObjectIdentifier> pa
384379        }
385380    }
386381
387-     private  static  boolean  maybeRecordDeleteErrors (DeleteObjectsResponse  response , DeletionExceptions  deletionExceptions ) {
382+     private  static  boolean  maybeRecordDeleteErrors (
383+         OperationPurpose  purpose ,
384+         DeleteObjectsResponse  response ,
385+         DeletionExceptions  deletionExceptions 
386+     ) {
388387        if  (response .hasErrors () == false ) {
389388            return  false ;
390389        }
@@ -394,8 +393,9 @@ private static boolean maybeRecordDeleteErrors(DeleteObjectsResponse response, D
394393        StringBuilder  sb  = null ;
395394
396395        for  (final  var  err  : errors ) {
397-             if  (deletionExceptions . ignoreNoSuchKey  && "NoSuchKey" .equals (err .code ())) {
396+             if  (purpose  !=  OperationPurpose . REPOSITORY_ANALYSIS  && "NoSuchKey" .equals (err .code ())) {
398397                // The blob does not exist, which is what we wanted, so let's count that as a win 
398+                 // (except for repo analysis where we can be certain that the blobs being deleted do all exist) 
399399                continue ;
400400            }
401401
0 commit comments