libnetwork: repository.get_SRPMS_name: cache file list to reduce network traffic
This commit is contained in:
@@ -221,28 +221,33 @@ getting list of files from"" \`${NOTE}$currurl/${NORM}'..."
|
|||||||
continue ;;
|
continue ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
currflist="$(mktemp -q -p /var/tmp -t flist.XXXXXXXX)" ||
|
currflist="/var/tmp/autospec_flist_$(echo "$currurl" | sed 's/[^a-zA-Z0-9._-]/_/g')"
|
||||||
notify.error $"can't create temporary files"
|
|
||||||
notify.debug "$FUNCNAME: currflist = $currflist"
|
notify.debug "$FUNCNAME: currflist = $currflist"
|
||||||
|
|
||||||
# NOTE: the trailing slash is necessary, do not remove it
|
# Cache flist file for 10 minutes to reduce network traffic
|
||||||
notify.debug "$FUNCNAME: curl $curlopts_debug --url $currurl/ -o $currflist"
|
if [ ! -e "$currflist" ] || find $currflist -mmin +10 | grep -q .; then
|
||||||
curl $curlopts --url $currurl/ -o $currflist
|
# NOTE: the trailing slash is necessary, do not remove it
|
||||||
let "retval = $?"
|
notify.debug "$FUNCNAME: curl $curlopts_debug --url $currurl/ -o $currflist"
|
||||||
notify.debug "$FUNCNAME: curl return code: $retval"
|
curl $curlopts --url $currurl/ -o $currflist
|
||||||
|
let "retval = $?"
|
||||||
|
notify.debug "$FUNCNAME: curl return code: $retval"
|
||||||
|
|
||||||
case "$retval" in
|
case "$retval" in
|
||||||
0) sed -i 's/\x0D$//;s/%2B/+/g' $currflist
|
0) sed -i 's/\x0D$//;s/%2B/+/g' $currflist
|
||||||
flist[$i]="$currflist" ;;
|
flist[$i]="$currflist" ;;
|
||||||
6) notify.warning $"couldn't resolve host"
|
6) notify.warning $"couldn't resolve host"
|
||||||
let "errors += 1" ;;
|
let "errors += 1" ;;
|
||||||
7) notify.warning $"failed to connect to host"
|
7) notify.warning $"failed to connect to host"
|
||||||
let "errors += 1" ;;
|
let "errors += 1" ;;
|
||||||
56) notify.warning $"failure in receiving network data"
|
56) notify.warning $"failure in receiving network data"
|
||||||
let "errors += 1" ;;
|
let "errors += 1" ;;
|
||||||
*) notify.warning $"curl error (exit code: $retval)"
|
*) notify.warning $"curl error (exit code: $retval)"
|
||||||
let "errors += 1" ;;
|
let "errors += 1" ;;
|
||||||
esac
|
esac
|
||||||
|
else
|
||||||
|
notify.debug "$FUNCNAME: using cached flist file $currflist"
|
||||||
|
flist[$i]="$currflist"
|
||||||
|
fi
|
||||||
|
|
||||||
[ -s "$currflist" ] || notify.warning $"cannot get the list of files"
|
[ -s "$currflist" ] || notify.warning $"cannot get the list of files"
|
||||||
|
|
||||||
@@ -281,11 +286,6 @@ $FUNCNAME: got_SPEC_FILENAME = ${got_SPEC_FILENAME[*]}"
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in ${!flist[@]}; do
|
|
||||||
notify.debug "$FUNCNAME: removing temporary file '${flist[$i]}'"
|
|
||||||
rm -f ${flist[$i]}
|
|
||||||
done
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user