@@ -18,18 +18,37 @@ mkdir -p ${WORKDIR}
1818# Clean up previous run.
1919rm -f ${WORKDIR} /tbs.md5-*
2020
21- find ${TARGETDIR} / -maxdepth 1 -type d -printf ' %P\n' | sort | while read ctrl; do
22- cat ${TARGETDIR} /${ctrl} /* .md5 2> /dev/null | while read hash file; do
23- echo " ${hash} ${TARGETDIR} /${ctrl} /${file} "
21+ # We "find" all the controller directories and process them in alphabetical
22+ # order.
23+ find ${TARGETDIR} -maxdepth 1 -mindepth 1 -type d -printf ' %P\n' | sort | while read ctrl; do
24+ find ${TARGETDIR} /${ctrl} -maxdepth 1 -mindepth 1 -type f -name ' *.tar.xz' | while read tb; do
25+ # Detect empty tar balls
26+ if [[ ! -s ${tb} ]]; then
27+ printf -- " Empty tar ball found: %s\n" " ${tb} " >&2
28+ continue
29+ fi
30+ _md5=${tb} .md5
31+ if [[ ! -f ${_md5} ]]; then
32+ printf -- " MD5 file for tar ball missing: %s\n" " ${tb} " >&2
33+ elif [[ ! -s ${_md5} ]]; then
34+ printf -- " Empty tar ball MD5 file found: %s\n" " ${_md5} " >&2
35+ else
36+ # For each controller, we read all the .md5 file contents re-
37+ # emitting those contents with a file name that contains the full
38+ # path.
39+ awk " { print \$ 1, \" ${TARGETDIR} /${ctrl} /\" \$ 2 }" ${_md5}
40+ fi
2441 done
42+ # All the output is captured into one file so that the requested
43+ # concurrency can be provided below.
2544done > ${WORKDIR} /tbs.md5 2> ${WORKDIR} /tbs.err
2645
2746cat ${WORKDIR} /tbs.err; echo " "
2847
29- # We use the `--number=r/N` form so that all the workers below will
30- # chew through the list together in alphabetical order, and reduces
31- # the possibility of one workre getting all the biggest tar balls to
32- # process .
48+ # We use the `--number=r/N` form so that all the workers below will chew
49+ # through the list together in alphabetical order. This makes it convenient
50+ # for an observer to understand how far along the bit-rot detection process
51+ # has progressed .
3352split --number=r/${NCPUS} ${WORKDIR} /tbs.md5 ${WORKDIR} /tbs.md5-
3453
3554for i in ${WORKDIR} /tbs.md5-* ; do
0 commit comments