refactor: check if folder exists before writing to paths

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
th33xitus
2022-10-31 15:55:12 +01:00
parent d2986976f6
commit 56192427b4

View File

@@ -597,7 +597,9 @@ function set_multi_instance_names() {
local name
local names=""
local services=$(find_klipper_systemd)
local services
services=$(find_klipper_systemd)
###
# if value of 'multi_instance_names' is not an empty
@@ -706,9 +708,10 @@ function get_instance_folder_path() {
fi
done
elif [[ -z ${instance_names} && $(find_klipper_systemd | wc -w) -gt 0 ]]; then
folder_paths+=("${HOME}/printer_data/${folder_name}")
else
folder_paths=()
path="${HOME}/printer_data/${folder_name}"
if [[ -d ${path} ]]; then
folder_paths+=("${path}")
fi
fi
echo "${folder_paths[@]}"