From: Timo Sirainen Date: Fri, 13 Oct 2017 09:34:01 +0000 (+0300) Subject: fs-compress: Allow compress level 0 to skip compression X-Git-Tag: 2.3.0.rc1~835 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7542b9c480889bb7d2c3c9288e0df0fbbce0b639;p=thirdparty%2Fdovecot%2Fcore.git fs-compress: Allow compress level 0 to skip compression This can be useful when combined with the "maybe-" prefix, so Dovecot will support reading compressed files without creating new ones. --- diff --git a/src/plugins/fs-compress/fs-compress.c b/src/plugins/fs-compress/fs-compress.c index ff1c84f8d1..5b9abca86d 100644 --- a/src/plugins/fs-compress/fs-compress.c +++ b/src/plugins/fs-compress/fs-compress.c @@ -70,7 +70,7 @@ fs_compress_init(struct fs *_fs, const char *args, const level_str = t_strdup_until(args, p++); if (str_to_uint(level_str, &fs->compress_level) < 0 || - fs->compress_level < 1 || fs->compress_level > 9) { + fs->compress_level > 9) { fs_set_error(_fs, "Invalid compression level parameter '%s'", level_str); return -1; } @@ -204,6 +204,11 @@ static void fs_compress_write_stream(struct fs_file *_file) { struct compress_fs_file *file = (struct compress_fs_file *)_file; + if (file->fs->compress_level == 0) { + fs_wrapper_write_stream(_file); + return; + } + i_assert(_file->output == NULL); file->temp_output = @@ -220,6 +225,9 @@ static int fs_compress_write_stream_finish(struct fs_file *_file, bool success) struct istream *input; int ret; + if (file->fs->compress_level == 0) + return fs_wrapper_write_stream_finish(_file, success); + if (_file->output != NULL) { if (_file->output->closed) success = FALSE;