From f4c16572706f0892cd2b95a1f3652b3a744aa1e6 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Wed, 10 Jun 2020 09:32:53 +0200 Subject: [PATCH] fix keyDB_async, count cleanup only on bot start --- bashbot.sh | 10 ++++++---- modules/jsonDB.sh | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index c917e02..82b0711 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -11,7 +11,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.96-pre-23-geb89aee +#### $$VERSION$$ v0.96-pre-24-g5b25821 # # Exit Codes: # - 0 sucess (hopefully) @@ -247,9 +247,6 @@ if ! _is_function jssh_newDB ; then exit 6 fi -# cleanup (remove double entries) countfile on startup -[ "${SOURCE}" != "yes" ] && jssh_deleteKeyDB_async "CLEAN_COUNTER_DATABASE_ON_STARTUP" "${COUNTFILE}" - ################# # BASHBOT COMMON functions # $1 URL, $2 filename in DATADIR @@ -803,6 +800,11 @@ start_bot() { # shellcheck disable=SC2064 trap "kill -9 $!; exit" EXIT INT HUP TERM QUIT fi + # cleanup countfile on startup + [ "${SOURCE}" != "yes" ] && jssh_deleteKeyDB_async "CLEAN_COUNTER_DATABASE_ON_STARTUP" "${COUNTFILE}" + + ########## + # bot is ready, start processing updates ... while true; do # adaptive sleep in ms rounded to next 0.1 s sleep "$(printf '%.1f' "$((nextsleep))e-3")" diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index 7d72e45..14b5d96 100644 --- a/modules/jsonDB.sh +++ b/modules/jsonDB.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.96-pre-17-gdeeef7e +#### $$VERSION$$ v0.96-pre-24-g5b25821 # # source from commands.sh to use jsonDB functions # @@ -280,9 +280,9 @@ jssh_deleteKeyDB_async() { [[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3 local DB; DB="$(jssh_checkDB "$2")" declare -A oldARR - jssh_readDB_async "oldARR" "$2" || return "$?" + Json2Array "oldARR" <"${DB}" unset oldARR["$1"] - jssh_writeDB_async "oldARR" "$2" + Array2Json "oldARR" >"${DB}" } jssh_getKeyDB_async() {