@@ -492,22 +492,21 @@ static void dump_index_check(map<RGWObjCategory, RGWStorageStats> existing_stats
492492}
493493
494494int RGWBucket::check_bad_index_multipart (RGWBucketAdminOpState& op_state,
495- RGWFormatterFlusher& flusher,
496- const DoutPrefixProvider *dpp, std::string *err_msg)
495+ RGWFormatterFlusher& flusher,
496+ const DoutPrefixProvider *dpp,
497+ std::string *err_msg)
497498{
498- bool fix_index = op_state.will_fix_index ();
499-
500- bool is_truncated;
501- map<string, bool > meta_objs;
502- map<rgw_obj_index_key, string> all_objs;
499+ const bool fix_index = op_state.will_fix_index ();
503500
504501 bucket = op_state.get_bucket ()->clone ();
505502
506503 rgw::sal::Bucket::ListParams params;
507-
508504 params.list_versions = true ;
509505 params.ns = RGW_OBJ_NS_MULTIPART;
510506
507+ std::map<std::string, bool > meta_objs;
508+ std::map<rgw_obj_index_key, std::string> all_objs;
509+ bool is_truncated;
511510 do {
512511 rgw::sal::Bucket::ListResults results;
513512 int r = bucket->list (dpp, params, listing_max_entries, results, null_yield);
@@ -519,20 +518,19 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
519518 }
520519 is_truncated = results.is_truncated ;
521520
522- vector<rgw_bucket_dir_entry>::iterator iter;
523- for (iter = results.objs .begin (); iter != results.objs .end (); ++iter) {
524- rgw_obj_index_key key = iter->key ;
521+ for (const auto & o : results.objs ) {
522+ rgw_obj_index_key key = o.key ;
525523 rgw_obj obj (bucket->get_key (), key);
526- string oid = obj.get_oid ();
524+ std:: string oid = obj.get_oid ();
527525
528526 int pos = oid.find_last_of (' .' );
529527 if (pos < 0 ) {
530528 /* obj has no suffix */
531529 all_objs[key] = oid;
532530 } else {
533531 /* obj has suffix */
534- string name = oid.substr (0 , pos);
535- string suffix = oid.substr (pos + 1 );
532+ std:: string name = oid.substr (0 , pos);
533+ std:: string suffix = oid.substr (pos + 1 );
536534
537535 if (suffix.compare (" meta" ) == 0 ) {
538536 meta_objs[name] = true ;
@@ -543,16 +541,15 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
543541 }
544542 } while (is_truncated);
545543
546- list<rgw_obj_index_key> objs_to_unlink;
544+ std:: list<rgw_obj_index_key> objs_to_unlink;
547545 Formatter *f = flusher.get_formatter ();
548546
549547 f->open_array_section (" invalid_multipart_entries" );
550548
551- for (auto aiter = all_objs.begin (); aiter != all_objs.end (); ++aiter) {
552- string& name = aiter->second ;
553-
549+ for (const auto & o : all_objs) {
550+ const std::string& name = o.second ;
554551 if (meta_objs.find (name) == meta_objs.end ()) {
555- objs_to_unlink.push_back (aiter-> first );
552+ objs_to_unlink.push_back (o. first );
556553 }
557554
558555 if (objs_to_unlink.size () > listing_max_entries) {
@@ -566,7 +563,7 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
566563 }
567564 }
568565
569- dump_mulipart_index_results (objs_to_unlink, flusher. get_formatter () );
566+ dump_mulipart_index_results (objs_to_unlink, f );
570567 flusher.flush ();
571568 objs_to_unlink.clear ();
572569 }
0 commit comments