Improve target/ cache logging

This commit is contained in:
Michael Vines 2019-05-12 21:28:12 -07:00
parent 06378d6db6
commit 426d06b89b
No known key found for this signature in database
GPG Key ID: 33F4FDEC4E0E88BD
2 changed files with 8 additions and 2 deletions

View File

@ -10,6 +10,8 @@
set -x
rsync -a --delete --link-dest="$PWD" target "$d"
du -hs "$d"
read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$d")
echo "--- ${cacheSizeInGB}GB: $d"
)
#

View File

@ -14,14 +14,18 @@ export PS4="++"
(
set -x
d=$HOME/cargo-target-cache/"$BUILDKITE_LABEL"
MAX_CACHE_SIZE=18 # gigabytes
if [[ -d $d ]]; then
du -hs "$d"
read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$d")
if [[ $cacheSizeInGB -gt 18 ]]; then
echo "$d has gotten too large, removing it"
echo "--- ${cacheSizeInGB}GB: $d"
if [[ $cacheSizeInGB -gt $MAX_CACHE_SIZE ]]; then
echo "--- $d is too large, removing it"
rm -rf "$d"
fi
else
echo "--- $d not present"
fi
mkdir -p "$d"/target