diff --git a/var/lib/gsl/scripts/gsl__db_manager b/var/lib/gsl/scripts/gsl__db_manager index c3f9772..95e0987 100644 --- a/var/lib/gsl/scripts/gsl__db_manager +++ b/var/lib/gsl/scripts/gsl__db_manager @@ -29,6 +29,19 @@ gsl_db_post_status=`awk -F"|" '{print $4}' <<< "$gsl_db_post_exists"` gsl__db_line_post() { case "$gsl_process" in Checked) + # Check if post exists in DB posts.db and get line / status + gsl__db_post_exists "$gsl_file_db_posts" + [[ "$gsl_checker_err" ]] && \ + [[ "$gsl_db_post_line_nbr" ]] \ + && sed -i "${gsl_db_post_line_nbr}d" "$gsl_file_db_posts" \ + && gsl__logs_print \ + "$gsl_log_w" \ + "DB" \ + "Post" \ + "Line:$gsl_db_post_line_nbr removed. Error in $gsl_post" \ + "$gsl_file_db_posts" \ + && return + gsl_db_line=` printf '%s%s%s%s%s\n' \ "$gsl_post_type|" \ @@ -36,10 +49,7 @@ case "$gsl_process" in "$gsl_post_hash|" \ "$gsl_post_size|" \ "$gsl_process|"` - - # case if post exists in DB posts.db ? - gsl__db_post_exists "$gsl_file_db_posts" - + if [[ "$gsl_db_post_exists" ]];then sed -i "${gsl_db_post_line_nbr}s/.*/$gsl_db_line/" \ "$gsl_file_db_posts" && \ @@ -47,7 +57,7 @@ case "$gsl_process" in "$gsl_log_w" \ "DB" \ "Post" \ - "$gsl_post - Replaced Hash: $gsl_post_hash" \ + "Line:REPLACED - $gsl_post - Hash: $gsl_post_hash" \ "$gsl_file_db_posts" gsl_checker_war=true @@ -58,7 +68,7 @@ case "$gsl_process" in "$gsl_log_i" \ "DB" \ "Post" \ - "$gsl_post - New Line. Hash: $gsl_post_hash" \ + "Line:NEW - $gsl_post - Hash: $gsl_post_hash" \ "$gsl_file_db_posts" fi ;; diff --git a/var/lib/gsl/scripts/gsl__post_checkers b/var/lib/gsl/scripts/gsl__post_checkers index 8408717..f8bf353 100644 --- a/var/lib/gsl/scripts/gsl__post_checkers +++ b/var/lib/gsl/scripts/gsl__post_checkers @@ -38,14 +38,13 @@ gsl__post_check_bcodes echo -ne "\r\033[2K" # End of checkers : show logs for war and err +gsl__db_line_post + [[ "$gsl_checker_war" ]] \ && gsl log -s -w [[ "$gsl_checker_err" ]] \ - && gsl log -s -e \ - && return - -gsl__db_line_post + && gsl log -s -e } #=======================================================================