From ab8c155ff75f0e717aed48e83798855b7a26984c Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sat, 12 Sep 2026 11:58:03 +0200 Subject: [PATCH] add checksum calculation --- albentohandy | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/albentohandy b/albentohandy index fd363fb..dfdb1a9 100755 --- a/albentohandy +++ b/albentohandy @@ -123,10 +123,28 @@ execute_program() execute "$workdir" || return $? } +checksum() +{ + local workdir="$1" + local checksum="$2" + + [ "$checksum" == "true" ] || return 0 + + cd "$workdir" || return 1 + find . -type f \ + | sort \ + | sed '/checksum/d' \ + | xargs sha256sum > checksum.sha256 + sha256sum --status --check checksum.sha256 \ + || errlog "checksum failed" \ + || return $? +} + convert_process() { local format="$1" local cover="$2" + local checksum="$3" local workdir="work.$$" [ -f "albumlist" ] \ @@ -136,12 +154,14 @@ convert_process() execute_program "$format.sh" "$workdir" || return $? cleanup_cover "$workdir" "$cover" || return $? [ "$format" != "flac" ] && cleanup_flac "$workdir" + checksum "$workdir" "$checksum" || return $? } main() { local format=${format:="vorbis"} local cover="false" + local checksum="false" check_programms || return $? load_config || return $? @@ -150,18 +170,19 @@ main() || errlog "missing MUSICPATH" \ || return $? - while getopts "3kfho" optname; do + while getopts "3cfhko" optname; do case "$optname" in "3") format="mp3" ;; - "k") cover="true" ;; + "c") checksum="true" ;; "f") format="flac" ;; "h") usage && return 0 ;; + "k") cover="true" ;; "o") format="opus" ;; "*") echo "unkwnon parameter" ;; esac done - convert_process "$format" "$cover" || return $$ + convert_process "$format" "$cover" "$checksum" || return $? } main "$@" -- 2.47.3