fix keyDB_async, count cleanup only on bot start

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-06-10 09:32:53 +02:00
parent 5b2582129b
commit f4c1657270
2 changed files with 9 additions and 7 deletions

View File

@ -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")"

View File

@ -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() {