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

This commit is contained in:
GoEdgeLab
2023-10-13 09:22:45 +08:00
parent 97b7ba1bd9
commit 9751f43c7a

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) {