2
0
Files
gitcaddy-runner/internal/pkg/envcheck/disk_unix.go
GitCaddy e0feb6bd4e
Some checks failed
CI / build-and-test (push) Failing after 30s
Release / build (amd64, darwin) (push) Failing after 1m20s
Release / build (arm64, darwin) (push) Failing after 1m32s
Release / build (amd64, windows) (push) Failing after 1m40s
Release / build (arm64, linux) (push) Successful in 1m30s
Release / release (push) Has been cancelled
Release / build (amd64, linux) (push) Has been cancelled
chore: Remove gitea-vet from build process
Use standard go vet instead of gitea-vet for copyright checks.
This allows MarketAlly copyright headers in new files.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 09:53:17 +00:00

44 lines
867 B
Go

// Copyright 2026 MarketAlly. All rights reserved.
// SPDX-License-Identifier: MIT
//go:build unix
package envcheck
import (
"golang.org/x/sys/unix"
)
// detectDiskSpace detects disk space on the specified path's filesystem (Unix version)
// If path is empty, defaults to "/"
func detectDiskSpace(path string) *DiskInfo {
if path == "" {
path = "/"
}
var stat unix.Statfs_t
err := unix.Statfs(path, &stat)
if err != nil {
// Fallback to root if the path doesn't exist
err = unix.Statfs("/", &stat)
if err != nil {
return nil
}
path = "/"
}
total := stat.Blocks * uint64(stat.Bsize)
free := stat.Bavail * uint64(stat.Bsize)
used := total - free
usedPercent := float64(used) / float64(total) * 100
return &DiskInfo{
Path: path,
Total: total,
Free: free,
Used: used,
UsedPercent: usedPercent,
}
}