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}"
|
||||
|
||||
# extract hash from name.
|
||||
local saved="${target##*-}"
|
||||
saved="${saved%%.*}"
|
||||
local data=($(_archive_parse ${target}))
|
||||
local saved=${data[2]}
|
||||
|
||||
# calculate actual hash.
|
||||
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
||||
|
@ -164,16 +164,16 @@ archive_prune()
|
|||
|
||||
# Iterate counter.
|
||||
((count++))
|
||||
|
||||
local name="${target%_*}"
|
||||
local data="${target##*_}"
|
||||
local time="${data%%-*}"
|
||||
|
||||
local data=($(_archive_parse ${target}))
|
||||
local name="${data[0]}"
|
||||
local time="${data[1]}"
|
||||
local copies=($(ls ${name}_*))
|
||||
|
||||
# Iterate each copy.
|
||||
for copy in "${copies[@]}"; do
|
||||
local copy_data="${copy##*_}"
|
||||
local copy_time="${copy_data%%-*}"
|
||||
local copy_data=($(_archive_parse ${copy}))
|
||||
local copy_time="${copy_data[1]}"
|
||||
|
||||
if [[ "${copy_time}" -lt "${time}" ]]; then
|
||||
echo -e "${name}: prune ${copy_time}."
|
||||
|
@ -219,8 +219,8 @@ unarchive()
|
|||
echo -e "${status}"
|
||||
|
||||
# extract hash from name.
|
||||
local saved="${target##*-}"
|
||||
saved="${saved%%.*}"
|
||||
local data=($(_archive_parse "${target}"))
|
||||
local saved="${data[2]}"
|
||||
|
||||
# calculate actual hash.
|
||||
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
||||
|
@ -369,6 +369,21 @@ archive_convert()
|
|||
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 -f archive archive_fast archive_check unarchive archive_name _ARCHIVE_DATE
|
||||
export _ARCHIVE_PATTERN
|
||||
|
|
Reference in a new issue