Fix caching when repository returns 302 or uses HTTP/2

This commit is contained in:
Matteo Rossini 2018-07-22 12:15:40 +02:00
parent 7f2247e6ee
commit 9594a05f77

View file

@ -423,7 +423,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
[ $SRCBASE != "ChangeLog.txt" ]||[ -z "$LEVEL" -o "$LEVEL" == "1" ]&&printf " File: %-20s -> %-20s .." "$CURREPO" "$SRCBASE" [ $SRCBASE != "ChangeLog.txt" ]||[ -z "$LEVEL" -o "$LEVEL" == "1" ]&&printf " File: %-20s -> %-20s .." "$CURREPO" "$SRCBASE"
[ $VERBOSE -eq 3 ]&&echo -n " ($CACHEFILE) " [ $VERBOSE -eq 3 ]&&echo -n " ($CACHEFILE) "
if [ $TOCACHE -eq 1 ];then if [ $TOCACHE -eq 1 ];then
curl --max-time 10 --location --head $SRCURL 2>/dev/null|grep -v -e ^Date: -e ^Set-Cookie: -e ^Expires: -e ^X-Varnish:|sed 's/ //' > $TMPDIR/cache.head curl --max-time 10 --location --head $SRCURL 2>/dev/null|tac|sed '/^HTTP/q'|tac|grep -v -i -e ^Date: -e ^Set-Cookie: -e ^Expires: -e ^X-Varnish:|sed 's/ //' > $TMPDIR/cache.head
echo "Url: $SRCURL" >> $TMPDIR/cache.head echo "Url: $SRCURL" >> $TMPDIR/cache.head
[ $VERBOSE -eq 3 ]&&(echo;cat $TMPDIR/cache.head|sed 's/^/ /') [ $VERBOSE -eq 3 ]&&(echo;cat $TMPDIR/cache.head|sed 's/^/ /')
if grep -q "^HTTP/.* 404" $TMPDIR/cache.head;then if grep -q "^HTTP/.* 404" $TMPDIR/cache.head;then
@ -449,7 +449,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
$CACHEDOWNLOADER $1 $SRCURL $CACHEDOWNLOADER $1 $SRCURL
ERR=$? ERR=$?
echo echo
if [ "$(ls -l $1 2>/dev/null|awk '{print $5}')" == "$(grep Content-Length: $TMPDIR/cache.head|awk '{print $2}')" ];then if [ "$(ls -l $1 2>/dev/null|awk '{print $5}')" == "$(grep -i Content-Length: $TMPDIR/cache.head|awk '{print $2}')" ];then
cp $1 $CACHEDIR/$CACHEFILE 2>/dev/null cp $1 $CACHEDIR/$CACHEFILE 2>/dev/null
cp $TMPDIR/cache.head $CACHEDIR/$CACHEFILE.head 2>/dev/null cp $TMPDIR/cache.head $CACHEDIR/$CACHEFILE.head 2>/dev/null
fi fi