feat: Add local_target variable and tests
This commit is contained in:
@ -37,7 +37,7 @@ validate_sources() {
|
||||
}
|
||||
|
||||
validate_targets() {
|
||||
# Check targets array.
|
||||
# Check targets array and set local_target variable.
|
||||
#
|
||||
# Usage: validate_targets ARRAY
|
||||
|
||||
@ -46,24 +46,28 @@ validate_targets() {
|
||||
|
||||
local array=("$@")
|
||||
local scheme=
|
||||
local file_scheme=0
|
||||
local file_targets=()
|
||||
|
||||
for uri in "${array[@]}"; do
|
||||
scheme="${uri%%:*}"
|
||||
case "$scheme" in
|
||||
file|ftp|sftp|rsync|s3|swift|sj|dav|davs)
|
||||
if [[ "$scheme" == file ]]; then
|
||||
(( file_scheme++ )) || true
|
||||
file_targets+=("$uri")
|
||||
fi
|
||||
;;
|
||||
*) echo "Error: Unsupported URI scheme: $scheme" >&2; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$file_scheme" -eq 0 ]; then
|
||||
if [ "${#file_targets[@]}" -eq 0 ]; then
|
||||
echo "Error: 'file' scheme is not set in targets." \
|
||||
"You must provide one or more targets with 'file' scheme." >&2
|
||||
exit 1
|
||||
else
|
||||
# Set local_target. This variable contains path to save local backups.
|
||||
# Files to additional targets will be coped from this directory.
|
||||
local_target="${file_targets[0]}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user