@@ -694,60 +694,62 @@ StorageReferenceInternal* StorageReferenceInternal::GetParent() {
694694 return new StorageReferenceInternal (storageUri_.GetParent (), storage_);
695695}
696696
697- Future<StorageListResult> StorageReferenceInternal::List (int max_results_per_page,
698- const char * page_token) {
697+ Future<StorageListResult> StorageReferenceInternal::List (
698+ int max_results_per_page, const char * page_token) {
699699 auto * future_api = future ();
700- auto handle = future_api->SafeAlloc <StorageListResult>(kStorageReferenceFnList );
700+ auto handle =
701+ future_api->SafeAlloc <StorageListResult>(kStorageReferenceFnList );
701702
702703 std::string token_str = page_token ? page_token : " " ;
703- auto send_request_funct{[&, max_results_per_page, token_str]() -> BlockingResponse* {
704- auto * future_api = future ();
705- auto handle = future_api->SafeAlloc <StorageListResult>(kStorageReferenceFnListInternal );
706- ReturnedListResponse* response =
707- new ReturnedListResponse (handle, future_api, AsStorageReference ());
704+ auto send_request_funct{
705+ [&, max_results_per_page, token_str]() -> BlockingResponse* {
706+ auto * future_api = future ();
707+ auto handle = future_api->SafeAlloc <StorageListResult>(
708+ kStorageReferenceFnListInternal );
709+ ReturnedListResponse* response =
710+ new ReturnedListResponse (handle, future_api, AsStorageReference ());
708711
709- storage::internal::Request* request = new storage::internal::Request ();
712+ storage::internal::Request* request = new storage::internal::Request ();
710713
711- // NOTE: The backend expects the base url for list to be the bucket, not the object.
712- // So we reconstruct it.
713- std::string list_url = storage_->get_scheme ();
714- list_url += " ://" ;
715- list_url += storage_->get_host ();
716- list_url += " :" ;
717- list_url += std::to_string (storage_->get_port ());
718- list_url += " /v0/b/" ;
719- list_url += bucket ();
720- list_url += " /o" ;
721-
722- std::string path = storageUri_.GetPath ().str ();
723- if (!path.empty () && path.back () != ' /' ) {
724- path += ' /' ;
725- }
714+ // NOTE: The backend expects the base url for list to be the bucket, not
715+ // the object. So we reconstruct it.
716+ std::string list_url = storage_->get_scheme ();
717+ list_url += " ://" ;
718+ list_url += storage_->get_host ();
719+ list_url += " :" ;
720+ list_url += std::to_string (storage_->get_port ());
721+ list_url += " /v0/b/" ;
722+ list_url += bucket ();
723+ list_url += " /o" ;
724+
725+ std::string path = storageUri_.GetPath ().str ();
726+ if (!path.empty () && path.back () != ' /' ) {
727+ path += ' /' ;
728+ }
726729
727- list_url += " ?prefix=" ;
728- if (!path.empty ()) {
729- list_url += rest::util::EncodeUrl (path);
730- }
731- list_url += " &delimiter=" ;
732- list_url += rest::util::EncodeUrl (" /" );
733- if (!token_str.empty ()) {
734- list_url += " &pageToken=" ;
735- list_url += rest::util::EncodeUrl (token_str);
736- }
737- list_url += " &maxResults=" ;
738- list_url += std::to_string (max_results_per_page);
730+ list_url += " ?prefix=" ;
731+ if (!path.empty ()) {
732+ list_url += rest::util::EncodeUrl (path);
733+ }
734+ list_url += " &delimiter=" ;
735+ list_url += rest::util::EncodeUrl (" /" );
736+ if (!token_str.empty ()) {
737+ list_url += " &pageToken=" ;
738+ list_url += rest::util::EncodeUrl (token_str);
739+ }
740+ list_url += " &maxResults=" ;
741+ list_url += std::to_string (max_results_per_page);
739742
740- PrepareRequestBlocking (request, list_url.c_str (), rest::util::kGet );
743+ PrepareRequestBlocking (request, list_url.c_str (), rest::util::kGet );
741744
742- RestCall (request, request->notifier (), response, handle.get (), nullptr ,
743- nullptr );
745+ RestCall (request, request->notifier (), response, handle.get (), nullptr ,
746+ nullptr );
744747
745- return response;
746- }};
748+ return response;
749+ }};
747750
748- SendRequestWithRetry (kStorageReferenceFnListInternal ,
749- send_request_funct, handle,
750- storage_->max_operation_retry_time ());
751+ SendRequestWithRetry (kStorageReferenceFnListInternal , send_request_funct,
752+ handle, storage_->max_operation_retry_time ());
751753 return ListLastResult ();
752754}
753755
0 commit comments