Skip to content

Commit

Permalink
perf: only create dirs if they do not already exist (#1566)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Ouellette <mouellette@cainc.com>
  • Loading branch information
mattyo161 and cainc-mouellette authored Jan 10, 2024
1 parent 2b9bec7 commit b6b8074
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions bin/asdf
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

set -o pipefail
if [[ "${ASDF_DEBUG}" == "1" ]]; then
set -x
fi

# shellcheck source=lib/utils.bash
. "$(dirname "$(dirname "$0")")/lib/utils.bash"
Expand Down
2 changes: 1 addition & 1 deletion lib/functions/plugins.bash
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ plugin_add_command() {
local plugin_path
plugin_path=$(get_plugin_path "$plugin_name")

mkdir -p "$(asdf_data_dir)/plugins"
[ -d "$(asdf_data_dir)/plugins" ] || mkdir -p "$(asdf_data_dir)/plugins"

if [ -d "$plugin_path" ]; then
printf '%s\n' "Plugin named $plugin_name already added"
Expand Down
6 changes: 3 additions & 3 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ get_install_path() {
local install_dir
install_dir="$(asdf_data_dir)/installs"

mkdir -p "${install_dir}/${plugin}"
[ -d "${install_dir}/${plugin}" ] || mkdir -p "${install_dir}/${plugin}"

if [ "$install_type" = "version" ]; then
printf "%s/%s/%s\n" "$install_dir" "$plugin" "$version"
Expand All @@ -81,7 +81,7 @@ get_download_path() {
local download_dir
download_dir="$(asdf_data_dir)/downloads"

mkdir -p "${download_dir}/${plugin}"
[ -d "${download_dir}/${plugin}" ] || mkdir -p "${download_dir}/${plugin}"

if [ "$install_type" = "version" ]; then
printf "%s/%s/%s\n" "$download_dir" "$plugin" "$version"
Expand Down Expand Up @@ -442,7 +442,7 @@ initialize_or_update_plugin_repository() {
git -C "$repository_path" reset --hard origin/master
fi

mkdir -p "$(asdf_data_dir)/tmp"
[ -d "$(asdf_data_dir)/tmp" ] || mkdir -p "$(asdf_data_dir)/tmp"
touch "$(asdf_data_dir)/tmp/repo-updated"
}

Expand Down

0 comments on commit b6b8074

Please sign in to comment.