number of streams is specified as optional argument now
This commit is contained in:
parent
975280a456
commit
ccd4d37027
19
prsync
19
prsync
|
|
@ -5,7 +5,7 @@ cat << EOF
|
||||||
A wrapper around rsync which partitions the input files to blocks of roughly
|
A wrapper around rsync which partitions the input files to blocks of roughly
|
||||||
equal sizes and transfers them in multiple streams in parallel.
|
equal sizes and transfers them in multiple streams in parallel.
|
||||||
|
|
||||||
Usage: $(basename $0) [rsync flags] <num_streams> <src>... <dest>
|
Usage: $(basename $0) [opt] <src>... <dest>
|
||||||
Options:
|
Options:
|
||||||
<num_streams> Number of blocks/transfer streams.
|
<num_streams> Number of blocks/transfer streams.
|
||||||
<src> Source files (potentially multiple files).
|
<src> Source files (potentially multiple files).
|
||||||
|
|
@ -14,12 +14,14 @@ Options:
|
||||||
-h, --help Print this message.
|
-h, --help Print this message.
|
||||||
-n, --dry-run Do not transfer any data.
|
-n, --dry-run Do not transfer any data.
|
||||||
-r, --recursive Copy directories recursively
|
-r, --recursive Copy directories recursively
|
||||||
|
-s, --streams <num> Use <num> parallel streams.
|
||||||
-v, --verbose List files as they are transferred.
|
-v, --verbose List files as they are transferred.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
declare -a positional flags_rsync flags_du
|
declare -a positional flags_rsync flags_du
|
||||||
|
declare -i num_streams=1
|
||||||
positional=()
|
positional=()
|
||||||
flags_rsync=('-R' '-v' '--info=stats0,misc0,flist0')
|
flags_rsync=('-R' '-v' '--info=stats0,misc0,flist0')
|
||||||
flags_du=('-b')
|
flags_du=('-b')
|
||||||
|
|
@ -49,6 +51,11 @@ while [[ $# -gt 0 ]]; do
|
||||||
flag_recursive=1
|
flag_recursive=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
'-s'|'--streams')
|
||||||
|
num_streams=$2
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
'-v'|'--verbose')
|
'-v'|'--verbose')
|
||||||
flag_verbose=1
|
flag_verbose=1
|
||||||
shift
|
shift
|
||||||
|
|
@ -66,13 +73,11 @@ done
|
||||||
|
|
||||||
declare -i num_args
|
declare -i num_args
|
||||||
num_args=${#positional[@]}
|
num_args=${#positional[@]}
|
||||||
[[ $num_args -lt 3 ]] && usage && exit 1
|
[[ $num_args -lt 2 ]] && usage && exit 1
|
||||||
|
|
||||||
# Parse <num_streams>
|
# Parse <num_streams>
|
||||||
declare -i num_streams
|
if [[ $num_streams -lt 1 ]]; then
|
||||||
num_streams=${positional[0]}
|
echo "Error: invalid number of streams" >&2
|
||||||
if [[ $num_streams -eq 0 ]]; then
|
|
||||||
echo "Error: invalid value for <num_streams> (${positional[0]})" >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -88,7 +93,7 @@ function walk_dir {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
declare -a src
|
declare -a src
|
||||||
for path in "${positional[@]:1:num_args-2}"; do
|
for path in "${positional[@]:0:num_args-1}"; do
|
||||||
if [[ -L ${path} ]] && [[ $flag_copy_links -eq 0 ]]; then
|
if [[ -L ${path} ]] && [[ $flag_copy_links -eq 0 ]]; then
|
||||||
continue
|
continue
|
||||||
elif [[ -f ${path} ]]; then
|
elif [[ -f ${path} ]]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue