diff options
Diffstat (limited to 'src/zen/cmds/cache_cmd.cpp')
| -rw-r--r-- | src/zen/cmds/cache_cmd.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/zen/cmds/cache_cmd.cpp b/src/zen/cmds/cache_cmd.cpp index bf5f308e1..37e7c8fd1 100644 --- a/src/zen/cmds/cache_cmd.cpp +++ b/src/zen/cmds/cache_cmd.cpp @@ -531,6 +531,8 @@ CacheGetCommand::CacheGetCommand() "<attachmenthash>"); m_Options.add_option("", "o", "output-path", "File path for output data", cxxopts::value(m_OutputPath), "<path>"); m_Options.add_option("", "t", "text", "Ouput content of cache entry record as text", cxxopts::value(m_AsText), "<text>"); + m_Options + .add_option("", "d", "decompress", "Decompress data when applicable. Default = true", cxxopts::value(m_Decompress), "<decompress>"); m_Options.parse_positional({"namespace", "bucket", "valuekey", "attachmenthash"}); m_Options.positional_help("namespace bucket valuekey attachmenthash"); } @@ -613,7 +615,17 @@ CacheGetCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } if (HttpClient::Response Result = Http.Download(Url, std::filesystem::temp_directory_path()); Result) { - IoBuffer ChunkData = Result.ResponsePayload; + auto TryDecompress = [](const IoBuffer& Buffer) -> IoBuffer { + IoHash RawHash; + uint64_t RawSize; + if (CompressedBuffer Compressed = CompressedBuffer::FromCompressed(SharedBuffer(Buffer), RawHash, RawSize)) + { + return Compressed.Decompress().AsIoBuffer(); + }; + return std::move(Buffer); + }; + + IoBuffer ChunkData = m_Decompress ? TryDecompress(Result.ResponsePayload) : Result.ResponsePayload; if (m_AsText) { std::string StringData = Result.ToText(); |