Skip to content

Commit

Permalink
split missing file and forceful fetch scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
m-fila committed Dec 18, 2024
1 parent 7162c64 commit 60214b3
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions .github/scripts/fetch_external_sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,26 @@ fetch_for_file() {
if [ -n "${line}" ] && [[ "${line}" == *.md ]] || [[ "${line}" == *.png ]]; then
# If the file exists do nothing, otherwise pull it in from github
local file_to_fetch=${file_dir}/${line}
if [ "${FORCE}" = true ] || ! ls "${file_to_fetch}" > /dev/null 2>&1; then
echo "${line} does not exist or force option is enabled. Trying to fetch it from github"
local outputdir=$(dirname ${file_to_fetch})
mkdir -p ${outputdir} # make the directory for the output

# Try a few github organizations
for org in key4hep HEP-FCC AIDASoft iLCSoft; do
echo "Trying to fetch from github organization: '${org}'"
if try_fetch ${org} ${line} ${file_dir}; then
echo "Fetched successfully from organization '${org}'"
break
fi
done
if [ "${FORCE}" = true ]; then
echo "Force option enabled. Trying to fetch '${line}' from github"
elif ! ls "${file_to_fetch}" > /dev/null 2>&1; then
echo "${line} does not exist. Trying to fetch it from github"
else
continue
fi

local outputdir=$(dirname ${file_to_fetch})
mkdir -p ${outputdir} # make the directory for the output

# Try a few github organizations
for org in key4hep HEP-FCC AIDASoft iLCSoft; do
echo "Trying to fetch from github organization: '${org}'"
if try_fetch ${org} ${line} ${file_dir}; then
echo "Fetched successfully from organization '${org}'"
break
fi
done

# Check again if we have successfully fetched the file
if ! ls "${file_to_fetch}" > /dev/null 2>&1; then
echo "Could not fetch file '${line}' from external sources" 1>&2
Expand Down

0 comments on commit 60214b3

Please sign in to comment.