From 9abbab23950229e43fb0bc247aec3628f97d239a Mon Sep 17 00:00:00 2001 From: remittor Date: Tue, 10 Dec 2019 11:18:52 +0300 Subject: [PATCH 1/3] Fix decompress file from PAXZ archives (incorrect content size) --- src/wcx_archive.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/wcx_archive.cpp b/src/wcx_archive.cpp index 64b7a57..57cf78f 100644 --- a/src/wcx_archive.cpp +++ b/src/wcx_archive.cpp @@ -651,10 +651,15 @@ int archive::extract_paxzst(LPCWSTR fn, UINT64 file_size, HANDLE & hDstFile) ZSTD_outBuffer outBuff = { m_dst.data(), m_dst.size(), 0 }; size_t readSizeHint = ZSTD_decompressStream(m_zst.ctx.get_ctx(), &outBuff, &inBuff); FIN_IF(ZSTD_isError(readSizeHint), 0x7176300 | E_EREAD); - if (outBuff.pos) { - BOOL x = WriteFile(hDstFile, m_dst.c_data(), (DWORD)outBuff.pos, &dw, NULL); - FIN_IF(!x || outBuff.pos != dw, 0x7176600 | E_EWRITE); - written += dw; + size_t sz = outBuff.pos; + if (written + sz >= m_cur_file->data_size) { + sz = (size_t)(m_cur_file->data_size - written); + readSizeHint = 0; /* stop decoding */ + } + if (sz) { + BOOL x = WriteFile(hDstFile, m_dst.c_data(), (DWORD)sz, &dw, NULL); + FIN_IF(!x || sz != dw, 0x7176600 | E_EWRITE); + written += sz; int ret = m_cb.tell_process_data(written); FIN_IF(ret == psCancel, 0); // user press Cancel } From b688ffffdc24cf68f69c6dac86292134dcc47264 Mon Sep 17 00:00:00 2001 From: remittor Date: Tue, 10 Dec 2019 13:04:46 +0300 Subject: [PATCH 2/3] Increase ZSTD compression level (9 -> 10) --- src/wcx_packer.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/wcx_packer.cpp b/src/wcx_packer.cpp index 958d4b2..a47b6aa 100644 --- a/src/wcx_packer.cpp +++ b/src/wcx_packer.cpp @@ -66,15 +66,13 @@ int packer::set_compression_level(int cpr_level) if (cpr_level <= 0) cpr_level = -1; - if (m_ctype == ctLz4) { - if (cpr_level > LZ4HC_CLEVEL_DEFAULT) - cpr_level = LZ4HC_CLEVEL_DEFAULT; - } - if (m_ctype == ctZstd) { - if (cpr_level > zst::MAX_CLEVEL) - cpr_level = zst::MAX_CLEVEL; - } + if (cpr_level > 9) + cpr_level = 9; /* LZ4HC_CLEVEL_DEFAULT = 9; ZSTD_MAX_CLEVEL = 22; */ + m_cpr_level = cpr_level; + if (m_ctype == ctZstd && m_cpr_level >= 1) { + m_cpr_level += 1; /* 9 -> 10 */ + } return 0; } @@ -245,8 +243,8 @@ int packer::pack_files(LPCWSTR SubPath, LPCWSTR SrcPath, LPCWSTR AddList) } set_block_size(m_buf.size()); + LOGi("%s: compression level = %d", __func__, m_cfg.get_compression_level()); set_compression_level(m_cfg.get_compression_level()); - LOGi("%s: compression level = %d", __func__, m_cpr_level); m_start_time = GetTickCount(); reset_ctx(true); From 1cc6de3e41e56810857c792c09e8809bccb3b9d1 Mon Sep 17 00:00:00 2001 From: remittor Date: Tue, 10 Dec 2019 13:22:34 +0300 Subject: [PATCH 3/3] Bump version to 0.4 --- src/wcx_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wcx_version.h b/src/wcx_version.h index ae18564..c188e45 100644 --- a/src/wcx_version.h +++ b/src/wcx_version.h @@ -1,7 +1,7 @@ #pragma once #define WCX_VER_MAJOR 0 -#define WCX_VER_MINOR 3 +#define WCX_VER_MINOR 4 #define WCX_VER_GET_STR(num) WCX_VER_GET_STR2(num) #define WCX_VER_GET_STR2(num) #num