refactor
This commit is contained in:
@ -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{};
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
{
|
||||
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(nf->get_read_buffer_size());
|
||||
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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user