]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fs-compress: Allow compress level 0 to skip compression
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 13 Oct 2017 09:34:01 +0000 (12:34 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 16 Oct 2017 06:41:48 +0000 (09:41 +0300)
This can be useful when combined with the "maybe-" prefix, so Dovecot will
support reading compressed files without creating new ones.

src/plugins/fs-compress/fs-compress.c

index ff1c84f8d106ce27e06c7255b3645b9ff646fc83..5b9abca86da4ddb4d21237160b65fb3da51f510a 100644 (file)
@@ -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;