From eddeff66181644ca340a19e817055c89b7b5a9d4 Mon Sep 17 00:00:00 2001 From: Michael De Roover Date: Sat, 25 Jul 2020 17:34:01 +0200 Subject: [PATCH] Re-add data file removal logic --- cv | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/cv b/cv index fcc5a87..ac1899d 100755 --- a/cv +++ b/cv @@ -4,8 +4,8 @@ ex(){ echo -e "> ${*}" $@ } -date=$(date +"%Y-%m-%d") -ydate=$(date -d yesterday +"%Y-%m-%d") +[ -z $date ] && date=$(date +"%Y-%m-%d") +[ -z $ydate ] && ydate=$(date -d yesterday +"%Y-%m-%d") title(){ w=36 printf "║ %-${w}s ║\n" "${*}" @@ -63,10 +63,23 @@ result(){ out Recovered recovered out Tests tests out "╰> Per 1M" testsPerOneMillion - if [ ! -f $data/$ydate-$country ] + if [ ! -f $data/$ydate-$country ] || [ $(get todayCases) == "0" ] then frame line - title "Stats for $country appear new." + if [ ! -f $data/$ydate-$country ] + then + title "Stats for $country appear new." + fi + if [ $(get todayCases) == "0" ] + then + if [ -z $norm ] + then + title "New cases are 0. Removing data file." + rm $data/$date-$country + else + title "New cases are 0. Keeping data file." + fi + fi frame bot else frame down