From: Paul Hänsch Date: Thu, 9 Jan 2020 03:05:32 +0000 (+0100) Subject: date sanitizing, cache invalidation X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=bec3776a5065a5026936ab2b7d77bbe60a52ddac;p=lobster date sanitizing, cache invalidation --- diff --git a/therapies/update_therapy.sh b/therapies/update_therapy.sh index ec8ccdc..406f4f9 100755 --- a/therapies/update_therapy.sh +++ b/therapies/update_therapy.sh @@ -26,7 +26,40 @@ tempfile="$_DATA/temp/${tpy}.tpy" # serialize POST array into file for key in $(POST_KEYS); do - [ "$key" != imagedata ] && printf %s:%s\\n "$key" "$(POST "$key" |sed ':X;N;$!bX; s;\n;\\n;g;')" + case "$key" in + imagedata) true ;; + session*_date) + value="$(POST "$key" |sed ':X;N;$!bX; s;\n;\\n;g;')" + y=0 mon=0 dom=0 + case $value in + *.*.*) IFS=. read dom mon y <<-END + ${value} + END + ;; + *.*.) IFS=. read dom mon <<-END + ${value} + END + ;; + */*/*) IFS=/ read mon dom y <<-END + ${value} + END + ;; + */*) IFS=/ read mon dom <<-END + ${value} + END + ;; + *-*-*) IFS=- read y mon dom <<-END + ${value} + END + ;; + esac + [ ! "$y" ] && y="$(date +%Y)" + [ "$y" -gt 0 -a "$y" -lt 100 ] && y="$((y + 2000))" + date -d "${y}-${mon}-${dom}" + && printf %s:%s\\n "$key" "$(date -d "${y}-${mon}-${dom}" +%F)" \ + || printf %s:\\n "$key" + ;; + *) printf %s:%s\\n "$key" "$(POST "$key" |sed ':X;N;$!bX; s;\n;\\n;g;')" ;; + esac done >"$tempfile" if [ "$(POST delete_session)" ]; then @@ -65,5 +98,6 @@ elif [ "$(POST imagedata)" ]; then fi mv "$tempfile" "$tpyfile" +rm -f "${_DATA}/cache/${tpy%%.*}.vcf.cache" REDIRECT "/therapies/${tpy%.*}/${tpy#*.}"