Don't use volumes when filesize is smaller than volume size
This commit is contained in:
parent
b6f5334011
commit
755cd36fb6
1 changed files with 7 additions and 5 deletions
|
|
@ -47,7 +47,10 @@ check_input() {
|
|||
|
||||
# Calculates a "smart" volume size so that each volume (including the final part) will be approximately the same size
|
||||
calc_smart_volumes() {
|
||||
total_size=$(du -s -BM "${input_file}" | grep -oP '^\d+') || return
|
||||
total_size=$(du -s -BM "${input_file}" | grep -oP '^\d+') || return 0
|
||||
|
||||
[[ $total_size -lt $size ]] && return 1
|
||||
|
||||
num_volumes=$(echo "($total_size + $size - 1) / $size" | bc)
|
||||
size=$(echo "($total_size + $num_volumes - 1) / $num_volumes" | bc)
|
||||
|
||||
|
|
@ -55,10 +58,9 @@ calc_smart_volumes() {
|
|||
}
|
||||
|
||||
set_volumes() {
|
||||
[[ -z "$size" ]] && return
|
||||
|
||||
calc_smart_volumes
|
||||
volumes="-v${size}m"
|
||||
if [[ -n "$size" ]]; then
|
||||
calc_smart_volumes && volumes="-v${size}m"
|
||||
fi
|
||||
|
||||
echo "Volumes set to '$volumes'" >&2
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue