From d3209a25bae68eb4abae6e7402df6cdc13d73e21 Mon Sep 17 00:00:00 2001 From: desktop Date: Tue, 31 Oct 2023 23:51:06 +0300 Subject: [PATCH] bash : archive : add progress for extraction. --- .linux/bash/module/archive.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.linux/bash/module/archive.sh b/.linux/bash/module/archive.sh index 25ea876..de4f595 100644 --- a/.linux/bash/module/archive.sh +++ b/.linux/bash/module/archive.sh @@ -144,15 +144,26 @@ unarchive() saved="${saved%%.*}" # calculate actual hash. - local actual=$(sha1sum "${target}" | cut -d\ -f1) + local actual=$(pv "${target}" | sha1sum | cut -d\ -f1) # extract if hash matched or show error if not. if [[ "${saved}" = "${actual}" ]]; then - echo "${status}: OK." - tar -xf "${target}" + echo "${status}: validation OK." + case "${target##*.}" in + "xz") + pv "${target}" | xz -d | tar -xf - + ;; + "gz") + pv "${target}" | gzip -d | tar -xf - + ;; + esac else - echo "${status}: failed." + echo "${status}: validation failed." + return 1 fi + + # report extraction complete. + echo "${status}: done." done }