2 Commits

Author SHA1 Message Date
  JustAnotherArchivist cbebafe588 Colourise sha1sum output 3 years ago
  JustAnotherArchivist 18a3305e79 Fix handling of filenames with spaces and ampersands 3 years ago
1 changed files with 2 additions and 2 deletions
Split View
  1. +2
    -2
      iasha1check

+ 2
- 2
iasha1check View File

@@ -3,7 +3,7 @@

identifier="$1"
escapedIdentifier="$(sed 's/[.[\*^$()+?{|]/\\&/g' <<<"${identifier}")"
readarray -t iasha1sums < <(curl -sL "https://archive.org/download/${identifier}/${identifier}_files.xml" | tr -d '\n' | grep -Po '<file .*?</file>' | grep 'source="original".*<sha1>' | sed 's,^.*name=",,; s,".*<sha1>, ,; s,</sha1>.*$,,' | grep -Pv "^${escapedIdentifier}"'(\.cdx\.(gz|idx)|_meta\.(sqlite|xml)) ' | awk '{ print $2 " " $1 }')
readarray -t iasha1sums < <(curl -sL "https://archive.org/download/${identifier}/${identifier}_files.xml" | tr -d '\n' | grep -Po '<file .*?</file>' | grep 'source="original".*<sha1>' | sed 's,^.*name=",,; s,".*<sha1>, ,; s,</sha1>.*$,,' | grep -Pv "^${escapedIdentifier}"'(\.cdx\.(gz|idx)|_meta\.(sqlite|xml)) ' | sed 's,&amp;,\&,g' | awk '{ print $NF " " substr($0, 1, length($0) - length($NF) - 1) }')

localFiles=()
while IFS= read -r -d $'\0' f; do localFiles+=("${f:2}"); done < <(find . -type f -print0)
@@ -41,7 +41,7 @@ fi
echo

echo "SHA-1 comparison:"
sha1sum -c < <(printf "%s\n" "${iasha1sums[@]}") > >(sed 's,^, ,') 2>&1
sha1sum -c < <(printf "%s\n" "${iasha1sums[@]}") > >(perl -pe 's,^(.*)(?<!: OK)$,'"${RED}"'\1'"${RESET}"',; s,: OK$,: '"${GREEN}OK${RESET}"',; s,^, ,') 2>&1
if [[ $? -eq 0 ]]
then
echo "SHA-1 comparison: ${GREEN}OK${RESET}"


Loading…
Cancel
Save