[bug] S3 provider should limit max key size to 1024 #31
This commit is contained in:
		| @@ -40,11 +40,11 @@ | |||||||
| #include "utils/time.hpp" | #include "utils/time.hpp" | ||||||
|  |  | ||||||
| namespace { | namespace { | ||||||
| [[nodiscard]] auto set_request_path(auto &request, const auto &cfg, | [[nodiscard]] auto set_request_path(auto &request, | ||||||
|                                     const std::string &object_name) |                                     const std::string &object_name) | ||||||
|     -> repertory::api_error { |     -> repertory::api_error { | ||||||
|   request.path = object_name; |   request.path = object_name; | ||||||
|   if ((cfg.bucket + request.path).substr(0U).size() > 1024U) { |   if (request.path.substr(1U).size() > 1024U) { | ||||||
|     return repertory::api_error::name_too_long; |     return repertory::api_error::name_too_long; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -137,7 +137,7 @@ auto s3_provider::create_directory_impl(const std::string &api_path, | |||||||
|     response_data = std::string(data.begin(), data.end()); |     response_data = std::string(data.begin(), data.end()); | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   auto res = set_request_path(put_dir, cfg, object_name + '/'); |   auto res = set_request_path(put_dir, object_name + '/'); | ||||||
|   if (res != api_error::success) { |   if (res != api_error::success) { | ||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
| @@ -244,7 +244,7 @@ auto s3_provider::create_path_directories(const std::string &api_path, | |||||||
|           response_data = std::string(data.begin(), data.end()); |           response_data = std::string(data.begin(), data.end()); | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|         res = set_request_path(put_dir, cfg, |         res = set_request_path(put_dir, | ||||||
|                                (is_encrypted ? cur_key : cur_path) + '/'); |                                (is_encrypted ? cur_key : cur_path) + '/'); | ||||||
|         if (res != api_error::success) { |         if (res != api_error::success) { | ||||||
|           return res; |           return res; | ||||||
| @@ -683,8 +683,8 @@ auto s3_provider::get_object_info(bool directory, const std::string &api_path, | |||||||
|                                              long /*response_code*/) { |                                              long /*response_code*/) { | ||||||
|       response_data = std::string(data.begin(), data.end()); |       response_data = std::string(data.begin(), data.end()); | ||||||
|     }; |     }; | ||||||
|     auto res = set_request_path(head, cfg, |     auto res = | ||||||
|                                 directory ? object_name + '/' : object_name); |         set_request_path(head, directory ? object_name + '/' : object_name); | ||||||
|     if (res != api_error::success) { |     if (res != api_error::success) { | ||||||
|       return res; |       return res; | ||||||
|     } |     } | ||||||
| @@ -848,7 +848,7 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size, | |||||||
|                                               long /*response_code*/) { |                                               long /*response_code*/) { | ||||||
|           read_buffer = response_data; |           read_buffer = response_data; | ||||||
|         }; |         }; | ||||||
|         res = set_request_path(get, cfg, object_name); |         res = set_request_path(get, object_name); | ||||||
|         if (res != api_error::success) { |         if (res != api_error::success) { | ||||||
|           return res; |           return res; | ||||||
|         } |         } | ||||||
| @@ -947,7 +947,7 @@ auto s3_provider::remove_directory_impl(const std::string &api_path) | |||||||
|     response_data = std::string(data.begin(), data.end()); |     response_data = std::string(data.begin(), data.end()); | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   auto res = set_request_path(del_dir, cfg, object_name + '/'); |   auto res = set_request_path(del_dir, object_name + '/'); | ||||||
|   if (res != api_error::success) { |   if (res != api_error::success) { | ||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
| @@ -998,7 +998,7 @@ auto s3_provider::remove_file_impl(const std::string &api_path) -> api_error { | |||||||
|                                                long /*response_code*/) { |                                                long /*response_code*/) { | ||||||
|     response_data = std::string(data.begin(), data.end()); |     response_data = std::string(data.begin(), data.end()); | ||||||
|   }; |   }; | ||||||
|   auto res = set_request_path(del_file, cfg, object_name); |   auto res = set_request_path(del_file, object_name); | ||||||
|   if (res != api_error::success) { |   if (res != api_error::success) { | ||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
| @@ -1081,7 +1081,7 @@ auto s3_provider::upload_file_impl(const std::string &api_path, | |||||||
|   }; |   }; | ||||||
|   put_file.source_path = source_path; |   put_file.source_path = source_path; | ||||||
|  |  | ||||||
|   auto res = set_request_path(put_file, cfg, object_name); |   auto res = set_request_path(put_file, object_name); | ||||||
|   if (res != api_error::success) { |   if (res != api_error::success) { | ||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user