mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Only try to create the subdir if does not already exist
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user