MCPcopy Create free account
hub / github.com/apache/arrow / RestoreTestBucket

Function RestoreTestBucket

cpp/src/arrow/filesystem/s3fs_test.cc:678–720  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676 }
677
678 Status RestoreTestBucket() {
679 // First empty the test bucket, and then re-upload initial test files.
680
681 Aws::S3::Model::Delete delete_object;
682 {
683 // Mostly taken from
684 // https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/cpp/example_code/s3/list_objects.cpp
685 Aws::S3::Model::ListObjectsV2Request req;
686 req.SetBucket(Aws::String{"bucket"});
687
688 Aws::String continuation_token;
689 do {
690 if (!continuation_token.empty()) {
691 req.SetContinuationToken(continuation_token);
692 }
693
694 auto outcome = client_->ListObjectsV2(req);
695
696 if (!outcome.IsSuccess()) {
697 return OutcomeToStatus("ListObjectsV2", outcome);
698 } else {
699 Aws::Vector<Aws::S3::Model::Object> objects = outcome.GetResult().GetContents();
700 for (const auto& object : objects) {
701 delete_object.AddObjects(
702 Aws::S3::Model::ObjectIdentifier().WithKey(object.GetKey()));
703 }
704
705 continuation_token = outcome.GetResult().GetNextContinuationToken();
706 }
707 } while (!continuation_token.empty());
708 }
709
710 {
711 Aws::S3::Model::DeleteObjectsRequest req;
712
713 req.SetDelete(std::move(delete_object));
714 req.SetBucket(Aws::String{"bucket"});
715
716 RETURN_NOT_OK(OutcomeToStatus("DeleteObjects", client_->DeleteObjects(req)));
717 }
718
719 return PopulateTestBucket();
720 }
721
722 Result<std::shared_ptr<S3FileSystem>> MakeNewFileSystem(
723 io::IOContext io_context = io::default_io_context()) {

Callers 1

TEST_FFunction · 0.85

Calls 5

OutcomeToStatusFunction · 0.85
DeleteObjectsMethod · 0.80
emptyMethod · 0.45
GetResultMethod · 0.45
GetKeyMethod · 0.45

Tested by

no test coverage detected