Skip to content

Commit

Permalink
Fix the "can't keep downloads when asked to" logic
Browse files Browse the repository at this point in the history
Currently, the warning which is intended to alert users that the download directory can't be kept only appears if they haven't asked for it to be. This change just rearranges the logic a bit so that the warning instead only appears if the download directory *should* be kept, but *can't* be kept (because it doesn't exist).

fixes asdf-vm#1711
  • Loading branch information
benblank committed May 12, 2024
1 parent ccdd47d commit 02a6a00
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/functions/installs.bash
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,16 @@ install_tool_version() {

local install_exit_code=$?
if [ $install_exit_code -eq 0 ] && [ $download_exit_code -eq 0 ]; then
# Remove download directory if --keep-download flag or always_keep_download config setting are not set
# If the download directory should be kept, but isn't available, warn the user
always_keep_download=$(get_asdf_config_value "always_keep_download")
if [ ! "$keep_download" = "true" ] && [ ! "$always_keep_download" = "yes" ]; then
if [ -d "$download_path" ]; then
rm -r "$download_path"
else
if [ "$keep_download" = "true" ] || [ "$always_keep_download" = "yes" ]; then
if [ ! -d "$download_path" ]; then
printf '%s\n' "asdf: Warn: You have configured asdf to preserve downloaded files (with always_keep_download=yes or --keep-download). But" >&2
printf '%s\n' "asdf: Warn: the current plugin ($plugin_name) does not support that. Downloaded files will not be preserved." >&2
fi
# Otherwise, remove the download directory if it exists
elif [ -d "$download_path" ]; then
rm -r "$download_path"
fi

reshim_command "$plugin_name" "$full_version"
Expand Down

0 comments on commit 02a6a00

Please sign in to comment.