Files
beads/cmd/bd/daemon_health_unix.go
Steve Yegge d5f2d91d04 fix(ci): more changes to fix failing CI (#415)
Fixes from maphew including:
- Remove test for deleted isPathWithinDir function
- Add gosec nolint directives for safe file operations
- Add rm -rf .beads before init in CI workflow
- Simplify panic handling and file operations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: maphew <maphew@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 22:24:29 -08:00

24 lines
655 B
Go

//go:build !windows && !wasm
package main
import (
"golang.org/x/sys/unix"
)
// checkDiskSpace returns the available disk space in MB for the given path.
// Returns (availableMB, true) on success, (0, false) on failure.
func checkDiskSpace(path string) (uint64, bool) {
var stat unix.Statfs_t
if err := unix.Statfs(path, &stat); err != nil {
return 0, false
}
// Calculate available space in bytes, then convert to MB
// Bavail is uint64, Bsize is int64; overflow is intentional/safe in this context
availableBytes := stat.Bavail * uint64(stat.Bsize) //nolint:gosec
availableMB := availableBytes / (1024 * 1024)
return availableMB, true
}