From f577c268b00f6cc55b162b852ee687663a2f1568 Mon Sep 17 00:00:00 2001
From: perry <pbtnguyen@gmail.com>
Date: Fri, 6 Dec 2024 03:27:04 -0500
Subject: [PATCH 2/2] fail build if downloaded or cached file is an HTML
 document

---
 build-stack | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/build-stack b/build-stack
index bd58672..b9a92e6 100755
--- a/build-stack
+++ b/build-stack
@@ -63,14 +63,17 @@ function die () {
 }
 
 function fetch_as () {
-    if [ -f $1 ] ; then
-        return
+    if ! [ -f $1 ] ; then
+        echo "--- Downloading.. $2"
+        if uname -a | grep --silent arwin ; then
+            curl -L -o $1 $2 || curl -L -k -o $1 $2
+        else
+            wget --no-check-certificate -O $1 $2
+        fi
     fi
-    echo "--- Downloading.. $2"
-    if uname -a | grep --silent arwin ; then
-        curl -L -o $1 $2 || curl -L -k -o $1 $2
-    else
-        wget --no-check-certificate -O $1 $2
+    if file $1 | grep -q HTML ; then
+       rm $1
+       return 1
     fi
 }
 
-- 
2.24.3 (Apple Git-128)

