Skip to content

Commit 3b566f4

Browse files
committed
Consult http_code and download_error_msg only for failed downloads.
1 parent 09142a2 commit 3b566f4

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/dotnet-install.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ get_specific_version_from_version() {
489489
local json_file="$5"
490490

491491
if [ -z "$json_file" ]; then
492-
if [[ "$version" == "latest" ]]; then
492+
if [[ "$version" == "latest" ]]; then
493493
local version_info
494494
version_info="$(get_latest_version_info "$azure_feed" "$channel" "$normalized_architecture" false)" || return 1
495495
say_verbose "get_specific_version_from_version: version_info=$version_info"
@@ -522,7 +522,7 @@ construct_download_link() {
522522
local specific_version="${4//[$'\t\r\n']}"
523523
local specific_product_version="$(get_specific_product_version "$1" "$4")"
524524
local osname="$5"
525-
525+
526526
local download_link=null
527527
if [[ "$runtime" == "dotnet" ]]; then
528528
download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz"
@@ -542,7 +542,7 @@ construct_download_link() {
542542
# azure_feed - $1
543543
# specific_version - $2
544544
get_specific_product_version() {
545-
# If we find a 'productVersion.txt' at the root of any folder, we'll use its contents
545+
# If we find a 'productVersion.txt' at the root of any folder, we'll use its contents
546546
# to resolve the version of what's in the folder, superseding the specified version.
547547
eval $invocation
548548

@@ -753,9 +753,8 @@ download() {
753753
elif machine_has "wget"; then
754754
downloadwget "$remote_path" "$out_path" || failed=true
755755
else
756-
unset http_code
757-
download_error_msg="Missing dependency: neither curl nor wget was found."
758-
break
756+
say_err "Missing dependency: neither curl nor wget was found."
757+
return 1
759758
fi
760759
761760
if [ "$failed" = false ] || [ $attempts -ge 3 ] || { [ ! -z $http_code ] && [ $http_code = "404" ]; }; then
@@ -905,10 +904,10 @@ install_dotnet() {
905904
906905
# The download function will set variables $http_code and $download_error_msg in case of failure.
907906
download "$download_link" "$zip_path" 2>&1 || download_failed=true
908-
primary_path_http_code="$http_code"; primary_path_download_error_msg="$download_error_msg"
909907
910908
# if the download fails, download the legacy_download_link
911909
if [ "$download_failed" = true ]; then
910+
primary_path_http_code="$http_code"; primary_path_download_error_msg="$download_error_msg"
912911
case $primary_path_http_code in
913912
404)
914913
say "The resource at $download_link is not available."
@@ -928,9 +927,9 @@ install_dotnet() {
928927
929928
# The download function will set variables $http_code and $download_error_msg in case of failure.
930929
download "$download_link" "$zip_path" 2>&1 || download_failed=true
931-
legacy_path_http_code="$http_code"; legacy_path_download_error_msg="$download_error_msg"
932930
933931
if [ "$download_failed" = true ]; then
932+
legacy_path_http_code="$http_code"; legacy_path_download_error_msg="$download_error_msg"
934933
case $legacy_path_http_code in
935934
404)
936935
say "The resource at $download_link is not available."
@@ -1132,10 +1131,10 @@ do
11321131
echo " --arch,-Architecture,-Arch"
11331132
echo " Possible values: x64, arm, and arm64"
11341133
echo " --os <system> Specifies operating system to be used when selecting the installer."
1135-
echo " Overrides the OS determination approach used by the script. Supported values: osx, linux, linux-musl, freebsd, rhel.6."
1136-
echo " In case any other value is provided, the platform will be determined by the script based on machine configuration."
1134+
echo " Overrides the OS determination approach used by the script. Supported values: osx, linux, linux-musl, freebsd, rhel.6."
1135+
echo " In case any other value is provided, the platform will be determined by the script based on machine configuration."
11371136
echo " Not supported for legacy links. Use --runtime-id to specify platform for legacy links."
1138-
echo " Refer to: https://aka.ms/dotnet-os-lifecycle for more information."
1137+
echo " Refer to: https://aka.ms/dotnet-os-lifecycle for more information."
11391138
echo " --runtime <RUNTIME> Installs a shared runtime only, without the SDK."
11401139
echo " -Runtime"
11411140
echo " Possible values:"
@@ -1160,7 +1159,7 @@ do
11601159
echo " Installs just the shared runtime bits, not the entire SDK."
11611160
echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)."
11621161
echo " -RuntimeId" The parameter is obsolete and may be removed in a future version of this script. Should be used only for versions below 2.1.
1163-
echo " For primary links to override OS or/and architecture, use --os and --architecture option instead."
1162+
echo " For primary links to override OS or/and architecture, use --os and --architecture option instead."
11641163
echo ""
11651164
echo "Install Location:"
11661165
echo " Location is chosen in following order:"
@@ -1197,7 +1196,7 @@ if [ "$dry_run" = true ]; then
11971196
if [ "$valid_legacy_download_link" = true ]; then
11981197
say "Legacy named payload URL: $legacy_download_link"
11991198
fi
1200-
repeatable_command="./$script_name --version "\""$specific_version"\"" --install-dir "\""$install_root"\"" --architecture "\""$normalized_architecture"\"" --os "\""$normalized_os"\"""
1199+
repeatable_command="./$script_name --version "\""$specific_version"\"" --install-dir "\""$install_root"\"" --architecture "\""$normalized_architecture"\"" --os "\""$normalized_os"\"""
12011200
if [[ "$runtime" == "dotnet" ]]; then
12021201
repeatable_command+=" --runtime "\""dotnet"\"""
12031202
elif [[ "$runtime" == "aspnetcore" ]]; then

0 commit comments

Comments
 (0)