Improved archive name generation

This commit is contained in:
PedoDeveloper 2024-11-11 13:02:25 +00:00
parent 755cd36fb6
commit 0c351f42ae

View file

@ -49,6 +49,7 @@ check_input() {
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
num_volumes=$(echo "($total_size + $size - 1) / $size" | bc)
@ -65,8 +66,9 @@ set_volumes() {
echo "Volumes set to '$volumes'" >&2
}
# Generates a random archive name of 20 alphanumeric characters
generate_name() {
archive="$archive_dir/$(base64 /dev/urandom | tr -dc [:alnum:] | head -c 20).7z"
archive="$archive_dir/$(tr -dc [:alnum:] < /dev/urandom | head -c 20).7z"
echo "Generated archive name '$archive'" >&2
}