]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
zstd: Fix support for compression-level>=20 when using binary 1342/head
authorHarry Mallon <hjmallon@gmail.com>
Wed, 11 Mar 2020 12:14:36 +0000 (12:14 +0000)
committerHarry Mallon <hjmallon@gmail.com>
Wed, 11 Mar 2020 12:14:38 +0000 (12:14 +0000)
* Requires '--ultra' argument

libarchive/archive_write_add_filter_zstd.c

index 280a20f67cb9a6ddcc6d40824564819860603d68..e02d1c1cb65a4527fde3db0bf10fbea86e5b3c73 100644 (file)
@@ -59,6 +59,8 @@ struct private_data {
 #endif
 };
 
+#define CLEVEL_STD_MAX 19 /* without using --ultra */
+
 static int archive_compressor_zstd_options(struct archive_write_filter *,
                    const char *, const char *);
 static int archive_compressor_zstd_open(struct archive_write_filter *);
@@ -300,6 +302,10 @@ archive_compressor_zstd_open(struct archive_write_filter *f)
        /* --no-check matches library default */
        archive_string_sprintf(&as, "zstd -%d --no-check", data->compression_level);
 
+       if (data->compression_level > CLEVEL_STD_MAX) {
+               archive_strcat(&as, " --ultra");
+       }
+
        f->write = archive_compressor_zstd_write;
        r = __archive_write_program_open(f, data->pdata, as.s);
        archive_string_free(&as);