1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 20:50:06 +00:00

fix(timeout): inherit helper state and pass checks

This commit is contained in:
Tw93
2026-03-14 08:32:11 +08:00
parent 0d2f217f28
commit 169be1e1f2
3 changed files with 21 additions and 15 deletions

View File

@@ -275,23 +275,22 @@ func getAPFSContainerFreeBytes(mountpoint string) (uint64, error) {
}
const key = "<key>APFSContainerFree</key>"
idx := strings.Index(out, key)
if idx == -1 {
_, rest, found := strings.Cut(out, key)
if !found {
return 0, fmt.Errorf("APFSContainerFree not found")
}
rest := out[idx+len(key):]
start := strings.Index(rest, "<integer>")
if start == -1 {
_, rest, found = strings.Cut(rest, "<integer>")
if !found {
return 0, fmt.Errorf("APFSContainerFree value not found")
}
rest = rest[start+len("<integer>"):]
end := strings.Index(rest, "</integer>")
if end == -1 {
value, _, found := strings.Cut(rest, "</integer>")
if !found {
return 0, fmt.Errorf("APFSContainerFree end tag not found")
}
val, err := strconv.ParseUint(strings.TrimSpace(rest[:end]), 10, 64)
val, err := strconv.ParseUint(strings.TrimSpace(value), 10, 64)
if err != nil {
return 0, fmt.Errorf("failed to parse APFSContainerFree: %v", err)
}