Skip to content

Commit

Permalink
Only try to create the subdir if does not already exist
Browse files Browse the repository at this point in the history
Signed-off-by: Christian König <ckoenig@posteo.de>
  • Loading branch information
yubiuser committed Aug 1, 2022
1 parent fb40a81 commit 5f83ba9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions deploy.sh
Expand Up @@ -37,8 +37,20 @@ unset IFS
old_path="."

for dir in "${path[@]}"; do
sftp -b - "${USER}"@"${HOST}" <<< "cd ${old_path}
-mkdir ${dir}"
mapfile -t dir_content <<< "$(
sftp -b - "${USER}"@"${HOST}" <<< "cd ${old_path}
ls -1"
)"

# Only try to create the subdir if does not already exist
if [[ "${dir_content[*]}" =~ "${dir}" ]]; then
echo "Dir: ${old_path}/${dir} already exists"
else
echo "Creating dir: ${old_path}/${dir}"
sftp -b - "${USER}"@"${HOST}" <<< "cd ${old_path}
-mkdir ${dir}"
fi

old_path="${old_path}/${dir}"
done

Expand Down

0 comments on commit 5f83ba9

Please sign in to comment.