From e65b2d235c300bb86cc7f960883ad919f75162e6 Mon Sep 17 00:00:00 2001 From: Shivshankar Date: Mon, 10 Jun 2024 16:24:04 -0400 Subject: [PATCH] Update rewriteConfigSaveOption function code to rewrite multiple save in one line. (#583) Currently, "config rewrite" writes some default value in the config file incase of empty config file specified. But it adds multiple "save" config entries as follows: ``` save 3600 1 save 300 100 save 60 10000 ``` After the fix the save will look like: ``` save 3600 1 300 100 60 10000 ``` --------- Signed-off-by: Shivshankar-Reddy --- src/config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index 13b66f00b5..a609a8f18d 100644 --- a/src/config.c +++ b/src/config.c @@ -1367,11 +1367,11 @@ void rewriteConfigSaveOption(standardConfig *config, const char *name, struct re if (!server.saveparamslen) { rewriteConfigRewriteLine(state, name, sdsnew("save \"\""), 1); } else { + line = sdsnew(name); for (j = 0; j < server.saveparamslen; j++) { - line = sdscatprintf(sdsempty(), "save %ld %d", (long)server.saveparams[j].seconds, - server.saveparams[j].changes); - rewriteConfigRewriteLine(state, name, line, 1); + line = sdscatprintf(line, " %ld %d", (long)server.saveparams[j].seconds, server.saveparams[j].changes); } + rewriteConfigRewriteLine(state, name, line, 1); } /* Mark "save" as processed in case server.saveparamslen is zero. */