From ca8982494ba37002377dd0bf78b023381a61bfce Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 1 Sep 2019 14:42:07 +0200 Subject: [PATCH] Store timestamp when the gravity table was last updated successfully. This fixes https://github.com/pi-hole/AdminLTE/issues/989 Signed-off-by: DL6ER --- gravity.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gravity.sh b/gravity.sh index 2fc26d49..98747f35 100755 --- a/gravity.sh +++ b/gravity.sh @@ -90,6 +90,16 @@ generate_gravity_database() { chmod g+w "${piholeDir}" "${gravityDBfile}" } +update_gravity_timestamp() { + # Update timestamp when the gravity table was last updated successfully + output=$( { sqlite3 "${gravityDBfile}" <<< "INSERT OR REPLACE INTO info (property,value) values (\"updated\",cast(strftime('%s', 'now') as int));"; } 2>&1 ) + status="$?" + + if [[ "${status}" -ne 0 ]]; then + echo -e "\\n ${CROSS} Unable to update gravity timestamp in database ${gravityDBfile}\\n ${output}" + fi +} + # Import domains from file and store them in the specified database table database_table_from_file() { # Define locals @@ -749,6 +759,8 @@ fi gravity_generateLocalList gravity_ShowCount +update_gravity_timestamp + gravity_Cleanup echo ""