summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-27 06:44:36 -0800
committerPaul Phillips <paulp@improving.org>2012-02-27 06:44:36 -0800
commitbbdc8f0bda4710b9e8d882af3c3b77b7cf922f5d (patch)
tree67eaf46e5c66d356b534c4b139044707be85643e /tools
parent44bc4b1221e9a41958e135eb21321726551960ac (diff)
downloadscala-bbdc8f0bda4710b9e8d882af3c3b77b7cf922f5d.tar.gz
scala-bbdc8f0bda4710b9e8d882af3c3b77b7cf922f5d.tar.bz2
scala-bbdc8f0bda4710b9e8d882af3c3b77b7cf922f5d.zip
Added tool for verifying jar cache.
And for removing corrupt files.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/verify-jar-cache33
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/verify-jar-cache b/tools/verify-jar-cache
new file mode 100755
index 0000000000..1e86264ecb
--- /dev/null
+++ b/tools/verify-jar-cache
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# 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