Keep cargo-target-cache size under 6GB-ish

This commit is contained in:
Michael Vines 2018-09-07 10:19:24 -07:00 committed by Grimes
parent e088833b81
commit f4947236dc
1 changed files with 10 additions and 0 deletions

View File

@ -7,6 +7,16 @@
#
(
d=$HOME/cargo-target-cache/"$CARGO_TARGET_CACHE_NAME"
if [[ -d $d ]]; then
du -hs "$d"
read -r cacheSizeInGB _ < <(du -s --block-size=1000000000 "$d")
if [[ $cacheSizeInGB -gt 5 ]]; then
echo "$d has gotten too large, removing it"
rm -rf "$d"
fi
fi
mkdir -p "$d"/target
set -x
rsync -a --delete --link-dest="$d" "$d"/target .