+download_lftp() {
+ local outfile=$1 url=$2 retval tmpfile
+ # TODO: use mktemp
+ tmpfile=$outfile.tmp
+ lftp -c "
+ $([ "$DEBUG" = "yes" ] && echo "debug 5;")
+ set ssl:verify-certificate no;
+ set net:max-retries $WGET_RETRIES;
+ set http:user-agent \"$USER_AGENT\";
+ pget -n 10 -c \"$url\" -o \"$tmpfile\"
+ "
+
+ retval=$?
+ if [ $retval -eq 0 ]; then
+ mv -f "$tmpfile" "$outfile"
+ else
+ rm -f "$tmpfile"
+ fi
+ return $retval
+}
+