archive : use tee to calc hash when archiving.

This commit is contained in:
Dmitry Voronin 2023-12-10 17:26:58 +03:00
parent 922e61b482
commit 0bf68be619

View file

@ -29,10 +29,10 @@ function archive() {
local name=$(parse_camel "${target}")
# create archive.
tar -c "${target}" | pv -s $(/usr/bin/du -sb "${target}" | awk '{print $1}') | xz -9e > "${name}".txz
local hash=$(tar -c "${target}" | pv -s $(/usr/bin/du -sb "${target}" | awk '{print $1}') | xz -9e | tee "${name}".txz | sha1sum | cut -d\ -f1)
# append hash to target name.
mv "${name}".txz "${name}"_${date}-$(pv "${name}".txz | sha1sum | cut -d\ -f1).txz
mv "${name}".txz "${name}"_${date}-${hash}.txz
# Show error.
if [[ ${?} != 0 ]]; then
@ -77,10 +77,10 @@ function archive_fast() {
local name=$(parse_camel "${target}")
# create archive.
tar -c "${target}" | pv -s $(/usr/bin/du -sb "${target}" | awk '{print $1}') | gzip -1 > "${name}".tgz
local hash=$(tar -c "${target}" | pv -s $(/usr/bin/du -sb "${target}" | awk '{print $1}') | gzip -1 | tee "${name}".tgz | sha1sum | cut -d\ -f1)
# append hash to target name.
mv "${name}".tgz "${name}"_${date}-$(pv "${name}".tgz | sha1sum | cut -d\ -f1).tgz
mv "${name}".tgz "${name}"_${date}-${hash}.tgz
# Show error.
if [[ $? != 0 ]]; then