mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
Fixes CI failures when the target dir is 0GB in size, which causes `expr` to output a non-zero exit code per the posix spec. See exit status section of https://www.man7.org/linux/man-pages/man1/expr.1p.html Release Notes: - N/A *or* Added/Fixed/Improved ...
26 lines
530 B
Bash
Executable file
26 lines
530 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=$(( ${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"
|
|
shopt -s dotglob
|
|
rm -rf target/*
|
|
fi
|