feat: New compression logic

This commit is contained in:
ge 2022-06-22 23:50:36 +03:00
parent 23403765e5
commit 1f2da45b25

View File

@ -28,7 +28,6 @@ handler::tar() {
local dst_path
local opts
local archive
local compr
local exclude
local file_ext
@ -68,35 +67,32 @@ handler::tar() {
exclude=
fi
# Overwrite __compression
if [ "$compression" ]; then
compr="$compression"
else
compr="$__compression"
fi
# Select filename extension by compression type.
# Make sure for the `--auto-compress` is enabled in __tar_options
# Refference: https://www.gnu.org/software/tar/manual/html_node/gzip.html
case "$compr" in
gzip|gz) file_ext='.tar.gz';; # gzip
tgz) file_ext='.tgz';; # gzip
taz) file_ext='.taz';; # gzip
compress|Z) file_ext='.tar.Z';; # compress
taZ) file_ext='.taZ';; # compress
bzip2|bz2) file_ext='.tar.bz2';; # bzip2
tz2) file_ext='.tz2';; # bzip2
tbz2) file_ext='.tbz2';; # bzip2
tbz) file_ext='.tbz';; # bzip2
lzip|lz) file_ext='.tar.lz';; # lzip
lzma) file_ext='.tar.lzma';; # lzma
tlz) file_ext='.tlz';; # lzma
lzop|lzo) file_ext='.tar.lzo';; # lzop
xz) file_ext='.tar.xz';; # xz
zstd|zst) file_ext='.tar.zst';; # zstd
tzst) file_ext='.tzst';; # zstd
*) file_ext='.tar.gz';; # Force gzip
esac
if [ "$compression" ]; then
# Make sure for the `--auto-compress` is enabled in __tar_options
# Refference: https://www.gnu.org/software/tar/manual/html_node/gzip.html
case "$compression" in
gzip|gz) file_ext='.tar.gz';; # gzip
tgz) file_ext='.tgz';; # gzip
taz) file_ext='.taz';; # gzip
compress|Z) file_ext='.tar.Z';; # compress
taZ) file_ext='.taZ';; # compress
bzip2|bz2) file_ext='.tar.bz2';; # bzip2
tz2) file_ext='.tz2';; # bzip2
tbz2) file_ext='.tbz2';; # bzip2
tbz) file_ext='.tbz';; # bzip2
lzip|lz) file_ext='.tar.lz';; # lzip
lzma) file_ext='.tar.lzma';; # lzma
tlz) file_ext='.tlz';; # lzma
lzop|lzo) file_ext='.tar.lzo';; # lzop
xz) file_ext='.tar.xz';; # xz
zstd|zst) file_ext='.tar.zst';; # zstd
tzst) file_ext='.tzst';; # zstd
*) file_ext='.tar';; # No compression
esac
else
file_ext='.tar'
fi
archive="${dst_path}/$(gen_backup_name "$file_ext")"