libnetwork: repository.get_SRPMS_name: cache file list to reduce network traffic
This commit is contained in:
@@ -221,10 +221,11 @@ 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"
|
||||
|
||||
# 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
|
||||
@@ -243,6 +244,10 @@ getting list of files from"" \`${NOTE}$currurl/${NORM}'..."
|
||||
*) 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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user