Skip to content
Snippets Groups Projects
Commit 2f4b3885 authored by Kristian Klausen's avatar Kristian Klausen :tada:
Browse files

Hide download parallelization behind a feature flag

ALBS_PARALLELIZE_DOWNLOAD=true to enable

It doesn't seem to improve performance just load on bugs.al.org.
parent 0fdd7df4
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
set -o nounset -o errexit -o pipefail
ALBS_PARALLELIZE_DOWNLOAD="${ALBS_PARALLELIZE_DOWNLOAD:-false}"
function get_newest_task_id() {
wget --output-document=- "https://bugs.archlinux.org/index.php?project=0&status[]=&changedfrom=2021-04-01" | grep --perl-regexp --only-matching --max-count 1 "(?<=task)[0-9]+"
......@@ -11,10 +12,13 @@ function generate_urls() {
function _download() {
set -o nounset -o errexit -o pipefail
local dir
dir="$(grep --only-matching "[0-9]*$" <<< "${2}")"
mkdir "${dir}"
cd "${dir}"
if [[ ${ALBS_PARALLELIZE_DOWNLOAD} = true ]]; then
local dir
dir="$(grep --only-matching "[0-9]*$" <<< "${2}")"
mkdir "${dir}"
cd "${dir}"
fi
local include_directories="user,themes,ajax,javascript"
if [ "${1}" = "true" ]; then
......@@ -37,18 +41,24 @@ function _download() {
}
function download() {
export -f _download
time echo "${2}" | xargs --max-procs=5 --max-args=200 bash -c "_download \"${1}\" \"\${@}\""
mkdir final
for d in */; do
if [[ ${d} = final/ ]]; then
continue
fi
rsync --recursive --ignore-existing "${d}" final/
rm -rf "${d}"
done
mv final/* .
rmdir final
if [[ ${ALBS_PARALLELIZE_DOWNLOAD} != true ]]; then
mapfile -t array <<< "${2}"
_download "${1}" "${array[@]}"
else
# broken?
export -f _download
time echo "${2}" | xargs --max-procs=5 --max-args=200 bash -c "_download \"${1}\" \"\${@}\""
mkdir final
for d in */; do
if [[ ${d} = final/ ]]; then
continue
fi
rsync --recursive --ignore-existing "${d}" final/
rm -rf "${d}"
done
mv final/* .
rmdir final
fi
}
function cleanup_html() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment