archive : parse archive data in _archive_parse.
This commit is contained in:
parent
c965527bfd
commit
6239070c6a
|
@ -122,8 +122,8 @@ archive_check()
|
||||||
echo -e "${status}"
|
echo -e "${status}"
|
||||||
|
|
||||||
# extract hash from name.
|
# extract hash from name.
|
||||||
local saved="${target##*-}"
|
local data=($(_archive_parse ${target}))
|
||||||
saved="${saved%%.*}"
|
local saved=${data[2]}
|
||||||
|
|
||||||
# calculate actual hash.
|
# calculate actual hash.
|
||||||
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
||||||
|
@ -164,16 +164,16 @@ archive_prune()
|
||||||
|
|
||||||
# Iterate counter.
|
# Iterate counter.
|
||||||
((count++))
|
((count++))
|
||||||
|
|
||||||
local name="${target%_*}"
|
local data=($(_archive_parse ${target}))
|
||||||
local data="${target##*_}"
|
local name="${data[0]}"
|
||||||
local time="${data%%-*}"
|
local time="${data[1]}"
|
||||||
local copies=($(ls ${name}_*))
|
local copies=($(ls ${name}_*))
|
||||||
|
|
||||||
# Iterate each copy.
|
# Iterate each copy.
|
||||||
for copy in "${copies[@]}"; do
|
for copy in "${copies[@]}"; do
|
||||||
local copy_data="${copy##*_}"
|
local copy_data=($(_archive_parse ${copy}))
|
||||||
local copy_time="${copy_data%%-*}"
|
local copy_time="${copy_data[1]}"
|
||||||
|
|
||||||
if [[ "${copy_time}" -lt "${time}" ]]; then
|
if [[ "${copy_time}" -lt "${time}" ]]; then
|
||||||
echo -e "${name}: prune ${copy_time}."
|
echo -e "${name}: prune ${copy_time}."
|
||||||
|
@ -219,8 +219,8 @@ unarchive()
|
||||||
echo -e "${status}"
|
echo -e "${status}"
|
||||||
|
|
||||||
# extract hash from name.
|
# extract hash from name.
|
||||||
local saved="${target##*-}"
|
local data=($(_archive_parse "${target}"))
|
||||||
saved="${saved%%.*}"
|
local saved="${data[2]}"
|
||||||
|
|
||||||
# calculate actual hash.
|
# calculate actual hash.
|
||||||
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
||||||
|
@ -369,6 +369,21 @@ archive_convert()
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_archive_parse()
|
||||||
|
{
|
||||||
|
local input="${1}"
|
||||||
|
local name="${input%_*}"
|
||||||
|
local format="${input##*.}"
|
||||||
|
local data="${input##*_}"; data="${data%.*}"
|
||||||
|
local date="${data%%-*}"
|
||||||
|
local hash="${data##*-}"
|
||||||
|
|
||||||
|
echo "${name}"
|
||||||
|
echo "${date}"
|
||||||
|
echo "${hash}"
|
||||||
|
echo "${format}"
|
||||||
|
}
|
||||||
|
|
||||||
# export everything, primarily for use with parallel..
|
# export everything, primarily for use with parallel..
|
||||||
export -f archive archive_fast archive_check unarchive archive_name _ARCHIVE_DATE
|
export -f archive archive_fast archive_check unarchive archive_name _ARCHIVE_DATE
|
||||||
export _ARCHIVE_PATTERN
|
export _ARCHIVE_PATTERN
|
||||||
|
|
Reference in a new issue