Alexei Strots | 0cb1134 | 2023-05-03 15:51:18 -0700 | [diff] [blame] | 1 | #include "aos/events/logging/s3_file_operations.h" |
Alexei Strots | 1bf05be | 2023-04-21 11:07:37 -0700 | [diff] [blame] | 2 | |
| 3 | #include "aos/events/logging/s3_fetcher.h" |
| 4 | |
| 5 | namespace aos::logger::internal { |
| 6 | |
Austin Schuh | 95460cc | 2023-06-26 11:53:10 -0700 | [diff] [blame^] | 7 | std::vector<FileOperations::File> Convert( |
| 8 | std::vector<std::pair<std::string, size_t>> &&input) { |
| 9 | std::vector<FileOperations::File> result; |
| 10 | result.reserve(input.size()); |
| 11 | for (std::pair<std::string, size_t> &i : input) { |
| 12 | result.emplace_back(FileOperations::File{ |
| 13 | .name = std::move(i.first), |
| 14 | .size = i.second, |
| 15 | }); |
| 16 | } |
| 17 | return result; |
| 18 | } |
Alexei Strots | 1bf05be | 2023-04-21 11:07:37 -0700 | [diff] [blame] | 19 | |
Austin Schuh | 95460cc | 2023-06-26 11:53:10 -0700 | [diff] [blame^] | 20 | S3FileOperations::S3FileOperations(std::string_view url) |
| 21 | : object_urls_(Convert(ListS3Objects(url))) {} |
| 22 | |
| 23 | void S3FileOperations::FindLogs(std::vector<File> *files) { |
Alexei Strots | 1bf05be | 2023-04-21 11:07:37 -0700 | [diff] [blame] | 24 | // We already have a recursive listing, so just grab all the objects from |
| 25 | // there. |
Austin Schuh | 95460cc | 2023-06-26 11:53:10 -0700 | [diff] [blame^] | 26 | for (const File &object_url : object_urls_) { |
| 27 | if (IsValidFilename(object_url.name)) { |
Alexei Strots | 1bf05be | 2023-04-21 11:07:37 -0700 | [diff] [blame] | 28 | files->push_back(object_url); |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
Austin Schuh | 95460cc | 2023-06-26 11:53:10 -0700 | [diff] [blame^] | 33 | } // namespace aos::logger::internal |