From: Jonathan Dieter Date: Fri, 12 Nov 2021 22:12:53 +0000 (+0000) Subject: Dictionary creation should be after compression format is set X-Git-Tag: archive/raspbian/1.2.1+ds1-1+rpi1^2~7^2~1^2~16 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fa3bdb9b662f5befe531de1e4d596c4b94057df5;p=zchunk.git Dictionary creation should be after compression format is set Signed-off-by: Jonathan Dieter --- diff --git a/src/lib/comp/comp.c b/src/lib/comp/comp.c index 7f4547b..02b8787 100644 --- a/src/lib/comp/comp.c +++ b/src/lib/comp/comp.c @@ -378,6 +378,7 @@ bool comp_soption(zckCtx *zck, zck_soption option, const void *value, return false; } if(option == ZCK_COMP_DICT) { + zck_log(ZCK_LOG_DEBUG, "Adding dictionary of size %li", length); zck->comp.dict = (char *)value; zck->comp.dict_size = length; } else { diff --git a/src/zck.c b/src/zck.c index b99de29..c6cf5c5 100644 --- a/src/zck.c +++ b/src/zck.c @@ -236,23 +236,6 @@ int main (int argc, char *argv[]) { } free(out_name); - /*if(!zck_set_ioption(zck, ZCK_COMP_TYPE, ZCK_COMP_NONE)) { - perror("Unable to set compression type\n"); - exit(1); - }*/ - if(dict_size > 0) { - if(!zck_set_soption(zck, ZCK_COMP_DICT, dict, dict_size)) { - dprintf(STDERR_FILENO, "%s\n", zck_get_error(zck)); - exit(1); - } - } - free(dict); - if(arguments.manual_chunk) { - if(!zck_set_ioption(zck, ZCK_MANUAL_CHUNK, 1)) { - dprintf(STDERR_FILENO, "%s\n", zck_get_error(zck)); - exit(1); - } - } if(arguments.compression_format) { if(strncmp(arguments.compression_format, "zstd", 4) == 0) { if(!zck_set_ioption(zck, ZCK_COMP_TYPE, ZCK_COMP_ZSTD)) { @@ -269,6 +252,19 @@ int main (int argc, char *argv[]) { exit(1); } } + if(dict_size > 0) { + if(!zck_set_soption(zck, ZCK_COMP_DICT, dict, dict_size)) { + dprintf(STDERR_FILENO, "%s\n", zck_get_error(zck)); + exit(1); + } + } + free(dict); + if(arguments.manual_chunk) { + if(!zck_set_ioption(zck, ZCK_MANUAL_CHUNK, 1)) { + dprintf(STDERR_FILENO, "%s\n", zck_get_error(zck)); + exit(1); + } + } if(arguments.uncompressed) { if(!zck_set_ioption(zck, ZCK_UNCOMP_HEADER, 1)) { dprintf(STDERR_FILENO, "%s\n", zck_get_error(zck));