private void deleteInternal(List<FileInfo> itemsToDelete, List<FileInfo> bucketsToDelete)
      throws IOException {
    // TODO(user): We might need to separate out children into separate batches from parents to
    // avoid deleting a parent before somehow failing to delete a child.
    // Delete children before their parents.
    //
    // Note: we modify the input list, which is ok for current usage.
    // We should make a copy in case that changes in future.
    itemsToDelete.sort(FILE_INFO_PATH_COMPARATOR.reversed());
    if (!itemsToDelete.isEmpty()) {
      List<StorageResourceId> objectsToDelete = new ArrayList<>(itemsToDelete.size());
      for (FileInfo fileInfo : itemsToDelete) {
        // TODO(b/110833109): populate generation ID in StorageResourceId when listing infos?
        objectsToDelete.add(
            new StorageResourceId(
                fileInfo.getItemInfo().getBucketName(),
                fileInfo.getItemInfo().getObjectName(),
                fileInfo.getItemInfo().getContentGeneration()));
      }
      gcs.deleteObjects(objectsToDelete);
    }
    if (!bucketsToDelete.isEmpty()) {
      List<String> bucketNames = new ArrayList<>(bucketsToDelete.size());
      for (FileInfo bucketInfo : bucketsToDelete) {
        bucketNames.add(bucketInfo.getItemInfo().getResourceId().getBucketName());
      }
      if (options.isBucketDeleteEnabled()) {
        gcs.deleteBuckets(bucketNames);
      } else {
        logger.atInfo().log(
            "Skipping deletion of buckets because enableBucketDelete is false: %s", bucketNames);
      }
    }
  }
private void deleteInternal(List<FileInfo> itemsToDelete, List<FileInfo> bucketsToDelete)
      throws IOException {
   
   
   
   
   
   
    itemsToDelete.sort(FILE_INFO_PATH_COMPARATOR.reversed());
    if (!itemsToDelete.isEmpty()) {
      List<StorageResourceId> objectsToDelete = new ArrayList<>(itemsToDelete.size());
      for (FileInfo fileInfo : itemsToDelete) {
       
        objectsToDelete.add(
            new StorageResourceId(
                fileInfo.getItemInfo().getBucketName(),
                fileInfo.getItemInfo().getObjectName(),
                fileInfo.getItemInfo().getContentGeneration()));
      }
      gcs.deleteObjects(objectsToDelete);
    }
    if (!bucketsToDelete.isEmpty()) {
      List<String> bucketNames = new ArrayList<>(bucketsToDelete.size());
      for (FileInfo bucketInfo : bucketsToDelete) {
        bucketNames.add(bucketInfo.getItemInfo().getResourceId().getBucketName());
      }
      if (options.isBucketDeleteEnabled()) {
        gcs.deleteBuckets(bucketNames);
      } else {
        logger.atInfo().log(
            "Skipping deletion of buckets because enableBucketDelete is false: %s", bucketNames);
      }
    }
  }
private void deleteinternal(list<fileinfo> itemstodelete, list<fileinfo> bucketstodelete) throws ioexception { itemstodelete.sort(file_info_path_comparator.reversed()); if (!itemstodelete.isempty()) { list<storageresourceid> objectstodelete = new arraylist<>(itemstodelete.size()); for (fileinfo fileinfo : itemstodelete) { objectstodelete.add( new storageresourceid( fileinfo.getiteminfo().getbucketname(), fileinfo.getiteminfo().getobjectname(), fileinfo.getiteminfo().getcontentgeneration())); } gcs.deleteobjects(objectstodelete); } if (!bucketstodelete.isempty()) { list<string> bucketnames = new arraylist<>(bucketstodelete.size()); for (fileinfo bucketinfo : bucketstodelete) { bucketnames.add(bucketinfo.getiteminfo().getresourceid().getbucketname()); } if (options.isbucketdeleteenabled()) { gcs.deletebuckets(bucketnames); } else { logger.atinfo().log( "skipping deletion of buckets because enablebucketdelete is false: %s", bucketnames); } } }