Files
oak-gpui/script/clear-target-dir-if-larger-than
T
Ben Kunkle b900ac2ac7 ci: Fix script/clear-target-dir-if-larger-than post #41652 (#42640)
Closes #ISSUE

The namespace runners mount the `target` directory to the cache drive,
so `rm -rf target` would fail with `Device Busy`. Instead we now do `rm
-rf target/* target/.*` to remove all files (including hidden files)
from the `target` directory, without removing the target directory
itself

Release Notes:

- N/A *or* Added/Fixed/Improved ...
2025-11-13 10:58:59 -05:00

26 lines
520 B
Bash
Executable File

#!/usr/bin/env bash
set -euxo pipefail
if [[ $# -ne 1 ]]; then
echo "usage: $0 <MAX_SIZE_IN_GB>"
exit 1
fi
if ! [[ -d target ]]; then
echo "target directory does not exist yet"
exit 0
fi
max_size_gb=$1
current_size=$(du -s target | cut -f1)
current_size_gb=$(expr ${current_size} / 1024 / 1024)
echo "target directory size: ${current_size_gb}gb. max size: ${max_size_gb}gb"
if [[ ${current_size_gb} -gt ${max_size_gb} ]]; then
echo "clearing target directory"
rm -rf target/* target/.*
fi