This commit is contained in:
2024-08-08 19:03:55 -05:00
parent 0b5efef569
commit e1ac9efaaa
4 changed files with 10 additions and 10 deletions

View File

@ -1269,7 +1269,7 @@ public:
data_buffer buffer(write_size);
if ((ret = request->decode(buffer.data(), buffer.size())) == 0) {
buffer = macaron::Base64::Decode(
std::string{buffer.begin(), buffer.end()});
std::string(buffer.begin(), buffer.end()));
write_size = buffer.size();
remote::file_offset write_offset{};

View File

@ -38,7 +38,7 @@ void packet::clear() {
auto packet::decode(std::string &data) -> packet::error_type {
const auto *str = reinterpret_cast<const char *>(&buffer_[decode_offset_]);
const auto length = strnlen(str, buffer_.size() - decode_offset_);
data = std::string{str, length};
data = std::string(str, length);
decode_offset_ += (length + 1);
return utils::from_api_error(api_error::success);

View File

@ -277,16 +277,16 @@ auto generate_sha256(const std::string &file_path) -> std::string {
std::to_string(res));
}
auto nf = utils::file::file::open_file(file_path);
if (not *nf) {
throw std::runtime_error("failed to open file|" + file_path);
}
{
data_buffer buffer(nf->get_read_buffer_size());
auto input_file = utils::file::file::open_file(file_path);
if (not *input_file) {
throw std::runtime_error("failed to open file|" + file_path);
}
data_buffer buffer(input_file->get_read_buffer_size());
std::uint64_t read_offset{0U};
std::size_t bytes_read{0U};
while (nf->read(buffer, read_offset, &bytes_read)) {
while (input_file->read(buffer, read_offset, &bytes_read)) {
if (not bytes_read) {
break;
}

View File

@ -131,7 +131,7 @@ TEST(utils_file, read_and_write_json_file_encrypted) {
decrypted_data));
EXPECT_STREQ(data.dump().c_str(),
nlohmann::json::parse(
std::string{decrypted_data.begin(), decrypted_data.end()})
std::string(decrypted_data.begin(), decrypted_data.end()))
.dump()
.c_str());
}