Skip to content

Commit

Permalink
#536: safe downloads (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Apr 9, 2021
1 parent c618fbe commit 38d5189
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions scripts/src/main/resources/scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi

# shellcheck source=scripts/environment-project
source "${DEVON_IDE_HOME}/scripts/environment-project" export
DEVON_DOWNLOAD_DIR="${DEVON_HOME_DIR}/Downloads"
DEVON_DOWNLOAD_DIR="${DEVON_HOME_DIR}/Downloads/devonfw-ide"

# $1: message (may contain newlines with \n)
# $2: optional exit code
Expand Down Expand Up @@ -344,6 +344,7 @@ function doDevonCommandAndReturn() {
function doDownload() {
doLicenseAgreement
local target_dir
local tmp_file
if [ -z "${3}" ]
then
target_dir="${DEVON_DOWNLOAD_DIR}"
Expand Down Expand Up @@ -371,11 +372,14 @@ function doDownload() {
then
curl_opt="--silent"
fi
curl ${curl_opt} -fL "${1}" -o "${target_dir}/${filename}"
tmp_file=$(mktemp -ut "${filename}.XXXXXX")
curl ${curl_opt} -fL "${1}" -o "${tmp_file}"
result=${?}
if [ "${result}" != 0 ]
then
doFail "Failed to download ${filename} from ${1}" ${result}
else
mv "${tmp_file}" "${target_dir}/${filename}"
fi
}

Expand Down
1 change: 0 additions & 1 deletion scripts/src/test/bash/test-setup
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function doGetVersion() {
cat pom.xml | grep "\(devon\|oasp\)4j.version>" | sed "s/.*>\([^<]*\)<.*/\1/"
}

echo "JAVA_VERSION=8u222b10" >> "conf/devon.properties"
doExtract ../../devonfw-ide-scripts-*.tar.gz
./setup "-" || exit 1
CLI="${PWD}/scripts/devon"
Expand Down

0 comments on commit 38d5189

Please sign in to comment.