From 892ba8c3cc0617d2087a2337d8c6e71524d7b49c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2020 09:12:21 +0100 Subject: ui-snapshot: add support for zstd compression This patch adds support for zstd [0] compressed snapshots (*.tar.zst). We enable multiple working threads (-T0), but keep default compression level. The latter can be influenced by environment variable. [0] https://www.zstd.net/ Signed-off-by: Christian Hesse --- ui-snapshot.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ui-snapshot.c') diff --git a/ui-snapshot.c b/ui-snapshot.c index 92cde42..556d3ed 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -91,6 +91,12 @@ static int write_tar_xz_archive(const char *hex, const char *prefix) return write_compressed_tar_archive(hex, prefix, argv); } +static int write_tar_zstd_archive(const char *hex, const char *prefix) +{ + char *argv[] = { "zstd", "-T0", NULL }; + return write_compressed_tar_archive(hex, prefix, argv); +} + const struct cgit_snapshot_format cgit_snapshot_formats[] = { /* .tar must remain the 0 index */ { ".tar", "application/x-tar", write_tar_archive }, @@ -98,6 +104,7 @@ const struct cgit_snapshot_format cgit_snapshot_formats[] = { { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive }, { ".tar.lz", "application/x-lzip", write_tar_lzip_archive }, { ".tar.xz", "application/x-xz", write_tar_xz_archive }, + { ".tar.zst", "application/x-zstd", write_tar_zstd_archive }, { ".zip", "application/x-zip", write_zip_archive }, { NULL } }; -- cgit v1.2.3