Loading fs_mgr/libsnapshot/libsnapshot_cow/cow_compress.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,13 @@ std::basic_string<uint8_t> CowWriter::Compress(const void* data, size_t length) << ", compression bound: " << bound << ", ret: " << compressed_size; return {}; } // Don't run compression if the compressed output is larger if (compressed_size >= length) { buffer.resize(length); memcpy(buffer.data(), data, length); } else { buffer.resize(compressed_size); } return buffer; } default: Loading fs_mgr/libsnapshot/libsnapshot_cow/cow_decompress.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -273,6 +273,18 @@ class Lz4Decompressor final : public IDecompressor { << actual_buffer_size << " bytes"; return false; } // If input size is same as output size, then input is uncompressed. if (stream_->Size() == output_size) { size_t bytes_read = 0; stream_->Read(output_buffer, output_size, &bytes_read); if (bytes_read != output_size) { LOG(ERROR) << "Failed to read all input at once. Expected: " << output_size << " actual: " << bytes_read; return false; } sink_->ReturnData(output_buffer, output_size); return true; } std::string input_buffer; input_buffer.resize(stream_->Size()); size_t bytes_read = 0; Loading Loading
fs_mgr/libsnapshot/libsnapshot_cow/cow_compress.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,13 @@ std::basic_string<uint8_t> CowWriter::Compress(const void* data, size_t length) << ", compression bound: " << bound << ", ret: " << compressed_size; return {}; } // Don't run compression if the compressed output is larger if (compressed_size >= length) { buffer.resize(length); memcpy(buffer.data(), data, length); } else { buffer.resize(compressed_size); } return buffer; } default: Loading
fs_mgr/libsnapshot/libsnapshot_cow/cow_decompress.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -273,6 +273,18 @@ class Lz4Decompressor final : public IDecompressor { << actual_buffer_size << " bytes"; return false; } // If input size is same as output size, then input is uncompressed. if (stream_->Size() == output_size) { size_t bytes_read = 0; stream_->Read(output_buffer, output_size, &bytes_read); if (bytes_read != output_size) { LOG(ERROR) << "Failed to read all input at once. Expected: " << output_size << " actual: " << bytes_read; return false; } sink_->ReturnData(output_buffer, output_size); return true; } std::string input_buffer; input_buffer.resize(stream_->Size()); size_t bytes_read = 0; Loading