From 469c179b328f93130fb7ccb5334585b15b94dc55 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 11 Sep 2021 21:54:42 +0200 Subject: [PATCH] Return early from recovery routine when integrity checks didn't show any database errors. Signed-off-by: DL6ER --- gravity.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gravity.sh b/gravity.sh index 911242f7..2d9b5dee 100755 --- a/gravity.sh +++ b/gravity.sh @@ -853,15 +853,16 @@ database_recovery() { echo -ne " ${INFO} ${str}..." if result="$(pihole-FTL sqlite3 "${gravityDBfile}" "PRAGMA integrity_check" 2>&1)"; then echo -e "${OVER} ${TICK} ${str} - no errors found" - else - echo -e "${OVER} ${CROSS} ${str} - errors found:" - while IFS= read -r line ; do echo " - $line"; done <<< "$result" - fi - str="Checking foreign keys of existing gravity database" - echo -ne " ${INFO} ${str}..." - if result="$(pihole-FTL sqlite3 "${gravityDBfile}" "PRAGMA foreign_key_check" 2>&1)"; then - echo -e "${OVER} ${TICK} ${str} - no errors found" + str="Checking foreign keys of existing gravity database" + echo -ne " ${INFO} ${str}..." + if result="$(pihole-FTL sqlite3 "${gravityDBfile}" "PRAGMA foreign_key_check" 2>&1)"; then + echo -e "${OVER} ${TICK} ${str} - no errors found" + return + else + echo -e "${OVER} ${CROSS} ${str} - errors found:" + while IFS= read -r line ; do echo " - $line"; done <<< "$result" + fi else echo -e "${OVER} ${CROSS} ${str} - errors found:" while IFS= read -r line ; do echo " - $line"; done <<< "$result"