macOS上检测磁盘是否不足时忽略/Developer/相关分区

This commit is contained in:
刘祥超
2023-10-13 09:22:45 +08:00
parent 2565b10491
commit 9f4a32b4ac

View File

@@ -19,6 +19,7 @@ import (
"os/exec"
"regexp"
"runtime"
"strings"
)
// CheckDiskPartitions 检查服务器磁盘空间
@@ -47,6 +48,14 @@ func CheckDiskPartitions(thresholdPercent float64) (path string, usage uint64, u
if p.Fstype != rootFS {
continue
}
// skip some specified partitions on macOS
if runtime.GOOS == "darwin" {
if strings.Contains(p.Mountpoint, "/Developer/") {
continue
}
}
stat, _ := disk.Usage(p.Mountpoint)
if stat != nil {
if stat.Used < 2*uint64(sizes.G) {