DB: removed line if post error

This commit is contained in:
Cyrille L 2022-02-17 11:28:04 +01:00
parent 332f1feb17
commit a2c340be3d
2 changed files with 19 additions and 10 deletions

View File

@ -29,6 +29,19 @@ gsl_db_post_status=`awk -F"|" '{print $4}' <<< "$gsl_db_post_exists"`
gsl__db_line_post() { gsl__db_line_post() {
case "$gsl_process" in case "$gsl_process" in
Checked) 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=` gsl_db_line=`
printf '%s%s%s%s%s\n' \ printf '%s%s%s%s%s\n' \
"$gsl_post_type|" \ "$gsl_post_type|" \
@ -37,9 +50,6 @@ case "$gsl_process" in
"$gsl_post_size|" \ "$gsl_post_size|" \
"$gsl_process|"` "$gsl_process|"`
# case if post exists in DB posts.db ?
gsl__db_post_exists "$gsl_file_db_posts"
if [[ "$gsl_db_post_exists" ]];then if [[ "$gsl_db_post_exists" ]];then
sed -i "${gsl_db_post_line_nbr}s/.*/$gsl_db_line/" \ sed -i "${gsl_db_post_line_nbr}s/.*/$gsl_db_line/" \
"$gsl_file_db_posts" && \ "$gsl_file_db_posts" && \
@ -47,7 +57,7 @@ case "$gsl_process" in
"$gsl_log_w" \ "$gsl_log_w" \
"DB" \ "DB" \
"Post" \ "Post" \
"$gsl_post - Replaced Hash: $gsl_post_hash" \ "Line:REPLACED - $gsl_post - Hash: $gsl_post_hash" \
"$gsl_file_db_posts" "$gsl_file_db_posts"
gsl_checker_war=true gsl_checker_war=true
@ -58,7 +68,7 @@ case "$gsl_process" in
"$gsl_log_i" \ "$gsl_log_i" \
"DB" \ "DB" \
"Post" \ "Post" \
"$gsl_post - New Line. Hash: $gsl_post_hash" \ "Line:NEW - $gsl_post - Hash: $gsl_post_hash" \
"$gsl_file_db_posts" "$gsl_file_db_posts"
fi fi
;; ;;

View File

@ -38,14 +38,13 @@ gsl__post_check_bcodes
echo -ne "\r\033[2K" echo -ne "\r\033[2K"
# End of checkers : show logs for war and err # End of checkers : show logs for war and err
gsl__db_line_post
[[ "$gsl_checker_war" ]] \ [[ "$gsl_checker_war" ]] \
&& gsl log -s -w && gsl log -s -w
[[ "$gsl_checker_err" ]] \ [[ "$gsl_checker_err" ]] \
&& gsl log -s -e \ && gsl log -s -e
&& return
gsl__db_line_post
} }
#======================================================================= #=======================================================================