]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-zlib: Support per-algorithm compression level
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 1 Apr 2021 09:41:40 +0000 (12:41 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 13 Apr 2021 06:18:28 +0000 (09:18 +0300)
src/config/old-set-parser.c
src/plugins/imap-zlib/imap-zlib-plugin.c

index 444e0ddac445d8c7546c3223c47d11bf00ca0337..d5302f8689c7761de319f978b97c8585b72e44f4 100644 (file)
@@ -733,6 +733,21 @@ static void socket_apply(struct config_parser_context *ctx)
        i_zero(&ctx->old->socket_set);
 }
 
+static bool
+old_settings_handle_path(struct config_parser_context *ctx,
+                        const char *key, const char *value)
+{
+       if (strcmp(str_c(ctx->str), "plugin/0/") == 0) {
+               if (strcmp(key, "imap_zlib_compress_level") == 0) {
+                       obsolete(ctx, "%s has been replaced by imap_compress_deflate_level", key);
+                       config_apply_line(ctx, key,
+                               t_strdup_printf("plugin/0/imap_compress_deflate_level=%s", value), NULL);
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
 bool old_settings_handle(struct config_parser_context *ctx,
                         enum config_line_type type,
                         const char *key, const char *value)
@@ -759,7 +774,7 @@ bool old_settings_handle(struct config_parser_context *ctx,
 
                        return old_settings_handle_root(ctx, key, value);
                }
-               break;
+               return old_settings_handle_path(ctx, key, value);
        case CONFIG_LINE_TYPE_SECTION_BEGIN:
                if (ctx->old->auth_section > 0)
                        return old_auth_section(ctx, key, value);
index 1035fbefb9195c34514a2840c788b6ab36edd870..df5508bf132ef6ebc97ab273f066defbea72b9d9 100644 (file)
@@ -102,11 +102,16 @@ static bool cmd_compress(struct client_command_context *cmd)
        client_skip_line(client);
        client_send_tagline(cmd, "OK Begin compression.");
 
-       value = mail_user_plugin_getenv(client->user,
-                                       "imap_zlib_compress_level");
-       if (value == NULL || str_to_int(value, &level) < 0 ||
-           level < handler->get_min_level() || level > handler->get_max_level()) {
-               i_error("imap_zlib_compress_level: Level must be between %d..%d",
+       const char *setting = t_strdup_printf("imap_compress_%s_level",
+                                             handler->name);
+       value = mail_user_plugin_getenv(client->user, setting);
+       if (value == NULL) {
+               level = handler->get_default_level();
+       } else if (str_to_int(value, &level) < 0 ||
+                  level < handler->get_min_level() ||
+                  level > handler->get_max_level()) {
+               i_error("%s: Level must be between %d..%d",
+                       setting,
                        handler->get_min_level(),
                        handler->get_max_level());
                level = handler->get_default_level();