about summary refs log tree commit diff stats
path: root/ui-snapshot.c
diff options
context:
space:
mode:
authorChristian Hesse2020-02-26 09:12:21 +0100
committerJason A. Donenfeld2020-03-12 19:56:39 -0600
commit892ba8c3cc0617d2087a2337d8c6e71524d7b49c (patch)
tree9f230da21b5cb0443a3058da543da6b13c959f71 /ui-snapshot.c
parenttests: add tests for xz compressed snapshots (diff)
downloadcgit-892ba8c3cc0617d2087a2337d8c6e71524d7b49c.tar.gz
cgit-892ba8c3cc0617d2087a2337d8c6e71524d7b49c.zip
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 <mail@eworm.de>
Diffstat (limited to 'ui-snapshot.c')
-rw-r--r--ui-snapshot.c7
1 files changed, 7 insertions, 0 deletions
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)
91 return write_compressed_tar_archive(hex, prefix, argv); 91 return write_compressed_tar_archive(hex, prefix, argv);
92} 92}
93 93
94static int write_tar_zstd_archive(const char *hex, const char *prefix)
95{
96 char *argv[] = { "zstd", "-T0", NULL };
97 return write_compressed_tar_archive(hex, prefix, argv);
98}
99
94const struct cgit_snapshot_format cgit_snapshot_formats[] = { 100const struct cgit_snapshot_format cgit_snapshot_formats[] = {
95 /* .tar must remain the 0 index */ 101 /* .tar must remain the 0 index */
96 { ".tar", "application/x-tar", write_tar_archive }, 102 { ".tar", "application/x-tar", write_tar_archive },
@@ -98,6 +104,7 @@ const struct cgit_snapshot_format cgit_snapshot_formats[] = {
98 { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive }, 104 { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive },
99 { ".tar.lz", "application/x-lzip", write_tar_lzip_archive }, 105 { ".tar.lz", "application/x-lzip", write_tar_lzip_archive },
100 { ".tar.xz", "application/x-xz", write_tar_xz_archive }, 106 { ".tar.xz", "application/x-xz", write_tar_xz_archive },
107 { ".tar.zst", "application/x-zstd", write_tar_zstd_archive },
101 { ".zip", "application/x-zip", write_zip_archive }, 108 { ".zip", "application/x-zip", write_zip_archive },
102 { NULL } 109 { NULL }
103}; 110};