Better output if file has not been downloaded because it has not been changed

This commit is contained in:
DL6ER 2016-12-17 23:46:28 +01:00
parent efaee2b68b
commit cd0c3f9418

View file

@ -105,9 +105,13 @@ gravity_collapse() {
gravity_patternCheck() { gravity_patternCheck() {
patternBuffer=$1 patternBuffer=$1
success=$2 success=$2
# check if the patternbuffer is a non-zero length file error=$3
if [ $success = true ]; then if [ $success = true ]; then
if [[ -s "${patternBuffer}" ]]; then # check if download was successful but list has not been modified
if [ "${error}" == "304" ]; then
echo "::: No changes detected, transport skipped!"
# check if the patternbuffer is a non-zero length file
elif [[ -s "${patternBuffer}" ]]; then
# Some of the blocklists are copyright, they need to be downloaded # Some of the blocklists are copyright, they need to be downloaded
# and stored as is. They can be processed for content after they # and stored as is. They can be processed for content after they
# have been saved. # have been saved.
@ -148,20 +152,20 @@ gravity_transport() {
# Analyze http response # Analyze http response
echo -n "::: Status: " echo -n "::: Status: "
case "$err" in case "$err" in
"200" ) echo "Success (OK)"; success=true;; "200" ) echo "Success (OK)"; success=true;;
"304" ) echo "Not modified"; success=false;; "304" ) echo "Not modified"; success=true;;
"403" ) echo "Forbidden"; success=false;; "403" ) echo "Forbidden"; success=false;;
"404" ) echo "Not found"; success=false;; "404" ) echo "Not found"; success=false;;
"408" ) echo "Time-out"; success=false;; "408" ) echo "Time-out"; success=false;;
"451" ) echo "Unavailable For Legal Reasons"; success=false;; "451" ) echo "Unavailable For Legal Reasons"; success=false;;
"521" ) echo "Web Server Is Down (Cloudflare)"; success=false;; "521" ) echo "Web Server Is Down (Cloudflare)"; success=false;;
"522" ) echo "Connection Timed Out (Cloudflare)"; success=false;; "522" ) echo "Connection Timed Out (Cloudflare)"; success=false;;
"500" ) echo "Internal Server Error"; success=false;; "500" ) echo "Internal Server Error"; success=false;;
* ) echo "Status $err"; success=false;; * ) echo "Status $err"; success=false;;
esac esac
# Process result # Process result
gravity_patternCheck "${patternBuffer}" ${success} gravity_patternCheck "${patternBuffer}" ${success} "${err}"
} }