diff --git a/modules/archive.sh b/modules/archive.sh index b6be4aa..3df2d7f 100755 --- a/modules/archive.sh +++ b/modules/archive.sh @@ -44,18 +44,16 @@ calc_smart_volumes() { total_size=$(du -s -BM "${input_file}" | grep -oP '^\d+') || return 0 # If total file size is smaller than volume size, don't pack it into volumes - [[ $total_size -lt $size ]] && return 1 + (( total_size < size )) && return 1 - num_volumes=$(echo "($total_size + $size - 1) / $size" | bc) - size=$(echo "($total_size + $num_volumes - 1) / $num_volumes" | bc) + num_volumes=$(( (total_size + size - 1) / size )) + size=$(( (total_size + num_volumes - 1) / num_volumes )) echo "Calculated smart volume size '$size'" >&2 } set_volumes() { - if [[ -n "$size" ]]; then - calc_smart_volumes && volumes="-v${size}m" - fi + [[ -n "$size" ]] && calc_smart_volumes && volumes="-v${size}m" echo "Volumes set to '$volumes'" >&2 }