File: verify-jar-cache

package info (click to toggle)
scala 2.11.12-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 62,828 kB
  • sloc: javascript: 28,808; java: 13,415; xml: 3,250; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (33 lines) | stat: -rwxr-xr-x 801 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
#
# Discovers files whose sha sum does not match the
# sha embedded in their directory name from ~/.sbt/cache/scala.
# Pass -f to remove them, otherwise it just prints them.

set -e
cd ~/.sbt/cache/scala
unset failed

unset removal
[[ "$1" == "-f" ]] && removal=true

for file in $(find . -type f); do
  sha=$(echo "${file:2}" | sed 's/\/.*$//')
  sum=$(shasum "$file" | sed 's/ .*$//')
  if [[ $sum != $sha ]]; then
    failed=true
    if [[ -n "$removal" ]]; then
      echo "Removing corrupt file $file, shasum=$sum"
      rm -rf $sha
    else
      echo "Found corrupt file $file, shasum=$sum."
    fi
  fi
done

if [[ -z "$failed" ]]; then
  echo "All cached files match their shas."
elif [[ -z "$removal" ]]; then
  echo ""
  echo "Run again with -f to remove the corrupt files."
fi