From 4b3dcbe9a51376955dd7f9813cfcd8d45f3a1e4f Mon Sep 17 00:00:00 2001 From: Binbin Date: Thu, 18 Jan 2024 10:42:48 +0800 Subject: [PATCH] code review: no need to reset is_manifest --- src/redis-check-aof.c | 3 +-- tests/integration/aof.tcl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/redis-check-aof.c b/src/redis-check-aof.c index 5e0efabc2e3..acd14dcdfc3 100644 --- a/src/redis-check-aof.c +++ b/src/redis-check-aof.c @@ -406,13 +406,12 @@ int fileIsManifest(char *filepath) { /* We will skip comments lines. * At present, the manifest format is fixed, see aofInfoFormat. - * We will be returned directly as long as it encounters other items. */ + * We will break directly as long as it encounters other items. */ if (buf[0] == '#') { continue; } else if (!memcmp(buf, "file", strlen("file"))) { is_manifest = 1; } else { - is_manifest = 0; break; } } diff --git a/tests/integration/aof.tcl b/tests/integration/aof.tcl index 885b2b3f41f..137b2d86339 100644 --- a/tests/integration/aof.tcl +++ b/tests/integration/aof.tcl @@ -541,6 +541,19 @@ tags {"aof external:skip"} { assert_match "*Start checking Multi Part AOF*Start to check BASE AOF (RDB format)*DB preamble is OK, proceeding with AOF tail*BASE AOF*is valid*Start to check INCR files*INCR AOF*is valid*All AOF files and manifest are valid*" $result } + test {Test redis-check-aof for Multi Part AOF contains a format error} { + create_aof_manifest $aof_dirpath $aof_manifest_file { + append_to_manifest "file appendonly.aof.1.base.aof seq 1 type b\n" + append_to_manifest "file appendonly.aof.1.incr.aof seq 1 type i\n" + append_to_manifest "!!!\n" + } + + catch { + exec src/redis-check-aof $aof_manifest_file + } result + assert_match "*Invalid AOF manifest file format*" $result + } + test {Test redis-check-aof only truncates the last file for Multi Part AOF in fix mode} { create_aof $aof_dirpath $aof_base_file { append_to_aof [formatCommand set foo hello]