1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 11:31:46 +00:00

fix(check): use numeric df output for disk space

This commit is contained in:
tw93
2026-01-29 11:15:14 +08:00
parent 0a46bf2077
commit 3a7f15aa32

View File

@@ -422,8 +422,11 @@ get_macos_update_labels() {
# ============================================================================ # ============================================================================
check_disk_space() { check_disk_space() {
local free_gb=$(command df -H / | awk 'NR==2 {print $4}' | sed 's/G//') # Use df -k to get KB values (always numeric), then calculate GB via math
local free_num=$(echo "$free_gb" | tr -d 'G' | cut -d'.' -f1) # This avoids unit suffix parsing issues (df -H can return MB or GB)
local free_kb=$(command df -k / | awk 'NR==2 {print $4}')
local free_gb=$(awk "BEGIN {printf \"%.1f\", $free_kb / 1048576}")
local free_num=$(awk "BEGIN {printf \"%d\", $free_kb / 1048576}")
export DISK_FREE_GB=$free_num export DISK_FREE_GB=$free_num