File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -46,13 +46,23 @@ run() {
4646 fi
4747
4848 get_etag() {
49- grep -i ETag "$CACHE/headers.txt" | sed -e 's/ETag: "\(.*\)"/\1/I' | tr -d '\r'
49+ # Swallow error when CACHE does not exist
50+ # Always allow even ETAG invalid to not fail pipeline
51+ grep -i ETag "$CACHE/headers.txt" 2>/dev/null | sed -e 's/ETag: "\(.*\)"/\1/I' | tr -d '\r' || true
5052 }
5153
52- if [ -f "$CACHE/headers.txt" ] && ETAG=$(get_etag); then
54+ ETAG=$(get_etag)
55+ # If invalid ETAG but CACHE exists: remove it
56+ if [ -z "$ETAG" ] && [ -d "$CACHE" ]; then
57+ echo "Cache in bad state; will remove $CACHE"
58+ rm -rf "$CACHE"
59+ fi
60+
61+ if [ -f "$CACHE/headers.txt" ] && [ ! -z "$ETAG" ]; then
5362 ETAG=(--header If-None-Match:\ $ETAG)
5463 else
5564 mkdir -p "$CACHE"
65+ ETAG=()
5666 fi
5767
5868 URL="https://pkgxdev.github.io/mash/$SCRIPTNAME"
You can’t perform that action at this time.
0 commit comments