From 265f82d08f82fce1ebba7f1169e03e0e4efc7d59 Mon Sep 17 00:00:00 2001 From: JunhuaY <81586673+JunhuaY@users.noreply.github.com> Date: Wed, 31 Mar 2021 03:49:06 +0800 Subject: [PATCH] re-fix config rewrite for empty save directive (#8722) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the bug was also discussed in #8716, and was solved in #8719, but incompletely: when the server is started, and the save option is default, if you issue the " config set save "" " to change the save option, and then issue the “config rewrite” command, the " save "" " won't be saved. --- src/config.c | 2 +- tests/unit/introspection.tcl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index b7381c670..459616eb4 100644 --- a/src/config.c +++ b/src/config.c @@ -1385,7 +1385,7 @@ void rewriteConfigSaveOption(struct rewriteConfigState *state) { * defaults from being used. */ if (!server.saveparamslen) { - rewriteConfigRewriteLine(state,"save",sdsnew("save \"\""),0); + rewriteConfigRewriteLine(state,"save",sdsnew("save \"\""),1); } else { for (j = 0; j < server.saveparamslen; j++) { line = sdscatprintf(sdsempty(),"save %ld %d", diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl index bf4addbe5..7ce89aa01 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -190,6 +190,14 @@ start_server {tags {"introspection"}} { r config rewrite restart_server 0 true false assert_equal [r config get save] {save {}} + + start_server {config "minimal.conf"} { + assert_equal [r config get save] {save {3600 1 300 100 60 10000}} + r config set save "" + r config rewrite + restart_server 0 true false + assert_equal [r config get save] {save {}} + } } # Config file at this point is at a wierd state, and includes all