Some checks failed
CI / build-and-test (push) Has been cancelled
Release / build (amd64, darwin) (push) Has been cancelled
Release / build (amd64, linux) (push) Has been cancelled
Release / build (amd64, windows) (push) Has been cancelled
Release / build (arm64, darwin) (push) Has been cancelled
Release / build (arm64, linux) (push) Has been cancelled
Release / release (push) Has been cancelled
- Add visionOS/xrOS SDK detection for Vision Pro development - Add PowerShell version detection (pwsh and powershell) with actual versions - Detect disk space on working directory filesystem (not just root) - Useful for runners using external/USB drives for builds - Add watchOS and tvOS suggested labels - Refactor disk detection to accept path parameter 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
44 lines
874 B
Go
44 lines
874 B
Go
//go:build unix
|
|
|
|
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
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,
|
|
}
|
|
}
|