diskspace

package
v0.2.0-beta.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package diskspace provides a single, reusable free-disk-space check (statfs's Bavail, the same "free space an unprivileged user could actually write" number GET /api/v1/system/doctor's disk_space check and GET /api/v1/system/status already surface), so disk-heavy operations elsewhere in this codebase (BuildKit builds, backup bookkeeping) can gate on it without reimplementing the syscall.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Free

func Free(path string) (int64, error)

Free reports the bytes free at path that an unprivileged user could write, per statfs's Bavail field (not Bfree, which includes root-reserved blocks).

func HumanBytes

func HumanBytes(bytes int64) string

HumanBytes renders bytes the same way web/src/lib/format.ts's own formatBytes does (binary units, one decimal place under 10 of a unit, none at or above), so a value read from Free and one read from the dashboard's own API response read the same regardless of which side rendered it. Negative bytes render as "0 B" rather than a negative unit, since this only ever wraps a real filesystem free-space value.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL