libnetwork: repository.get_SRPMS_name: cache file list to reduce network traffic

This commit is contained in:
2025-09-30 09:19:52 +02:00
parent 9564965f43
commit 07ead0acd3

View File

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