achive & name : add report for failed checks count.
This commit is contained in:
parent
fa4c85ade8
commit
84ccaddf26
|
@ -2,8 +2,8 @@
|
||||||
archive()
|
archive()
|
||||||
{
|
{
|
||||||
local target="$@" # target file(s).
|
local target="$@" # target file(s).
|
||||||
local count=1
|
local count=1 # processed count.
|
||||||
local total=$#
|
local total=$# # total to process.
|
||||||
|
|
||||||
# set dafult value to target all supported archives.
|
# set dafult value to target all supported archives.
|
||||||
if [[ "$target" = "" ]]; then
|
if [[ "$target" = "" ]]; then
|
||||||
|
@ -32,8 +32,8 @@ archive()
|
||||||
archive_fast()
|
archive_fast()
|
||||||
{
|
{
|
||||||
local target="$@" # target file(s).
|
local target="$@" # target file(s).
|
||||||
local count=1
|
local count=1 # processed count.
|
||||||
local total=$#
|
local total=$# # total to process.
|
||||||
|
|
||||||
# set dafult value to target all supported archives.
|
# set dafult value to target all supported archives.
|
||||||
if [[ "$target" = "" ]]; then
|
if [[ "$target" = "" ]]; then
|
||||||
|
@ -64,8 +64,9 @@ archive_check()
|
||||||
local target="$@" # target file(s).
|
local target="$@" # target file(s).
|
||||||
local saved # saved hash value.
|
local saved # saved hash value.
|
||||||
local actual # actual file hash value.
|
local actual # actual file hash value.
|
||||||
local count=1
|
local count=1 # processed count.
|
||||||
local total=$#
|
local total=$# # total to process.
|
||||||
|
local failed=0 # total failed checks.
|
||||||
|
|
||||||
# set dafult value to target all supported archives.
|
# set dafult value to target all supported archives.
|
||||||
if [[ "$target" = "" ]]; then
|
if [[ "$target" = "" ]]; then
|
||||||
|
@ -89,12 +90,18 @@ archive_check()
|
||||||
if [[ "$actual" = "$saved" ]]; then
|
if [[ "$actual" = "$saved" ]]; then
|
||||||
echo "${status}: OK."
|
echo "${status}: OK."
|
||||||
else
|
else
|
||||||
echo "${status}: failed."
|
echo -e "${color_red}${status}: failed.${color_default}"
|
||||||
|
((failed++))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# increment counter.
|
# increment counter.
|
||||||
((count++))
|
((count++))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# report if any failed.
|
||||||
|
if [[ ${failed} -gt 0 ]]; then
|
||||||
|
echo -e "${color_bred}Items failed to validate: ${failed}.${color_default}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# extract previously created archive with checksum validation.
|
# extract previously created archive with checksum validation.
|
||||||
|
@ -103,8 +110,8 @@ unarchive()
|
||||||
local target="$@" # target file(s).
|
local target="$@" # target file(s).
|
||||||
local saved # saved hash value.
|
local saved # saved hash value.
|
||||||
local actual # actual file hash value.
|
local actual # actual file hash value.
|
||||||
local count=1
|
local count=1 # processed count.
|
||||||
local total=$#
|
local total=$# # total to process.
|
||||||
|
|
||||||
# set dafult value to target all supported archives.
|
# set dafult value to target all supported archives.
|
||||||
if [[ "$target" = "" ]]; then
|
if [[ "$target" = "" ]]; then
|
||||||
|
|
|
@ -121,33 +121,41 @@ name_hash_check()
|
||||||
local files="$@"
|
local files="$@"
|
||||||
local count=1
|
local count=1
|
||||||
local total=$#
|
local total=$#
|
||||||
|
local failed=0
|
||||||
|
|
||||||
# all files by default.
|
# all files by default.
|
||||||
if [[ "$files" = "" ]]; then
|
if [[ "$files" = "" ]]; then
|
||||||
files="[^.]*"
|
files="[^.]*"
|
||||||
total=$(ls -p | grep -v / | wc -l)
|
total=$(ls -p | grep -v / | wc -l)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# process.
|
# process.
|
||||||
for file in $files; do
|
for file in $files; do
|
||||||
# process only files.
|
# process only files.
|
||||||
if [[ -f "$file" ]]; then
|
if [[ -f "$file" ]]; then
|
||||||
|
# status info.
|
||||||
|
local status="[$count/$total] $file"
|
||||||
|
|
||||||
# extract hashes.
|
# extract hashes.
|
||||||
stored="${file%%.*}"
|
stored="${file%%.*}"
|
||||||
actual=$(sha1sum -- "$file" | cut -d\ -f1)
|
actual=$(sha1sum -- "$file" | cut -d\ -f1)
|
||||||
|
|
||||||
# compare hashes.
|
# compare hashes.
|
||||||
echo -n "[$count/$total] $file: "
|
|
||||||
if [[ "$stored" = "$actual" ]]; then
|
if [[ "$stored" = "$actual" ]]; then
|
||||||
echo "OK."
|
echo -e "${status}: OK."
|
||||||
else
|
else
|
||||||
echo "failed."
|
echo -e "${color_red}${status}: failed.${color_default}"
|
||||||
|
((failed++))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# increment count.
|
# increment count.
|
||||||
((count++))
|
((count++))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# report if any failed.
|
||||||
|
if [[ ${failed} -gt 0 ]]; then
|
||||||
|
echo -e "${color_bred}Items failed to validate: ${failed}.${color_default}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# rename files for Jellyfin series, i.e. Episode S01E01.mkv
|
# rename files for Jellyfin series, i.e. Episode S01E01.mkv
|
||||||
|
|
Reference in a new issue