diskfree

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package diskfree measures the filesystem holding a directory: how big it is, how much of it is in use and how much this process could still write.

It exists because several subsystems need the same numbers and none of them should own them: the staged-upload guard (internal/staging), which refuses an upload the disk cannot hold; the search index rebuild (internal/search), which builds a second copy of the index alongside the live one and must refuse loudly rather than fill the disk; and the local storage driver, whose answer is what `df` shows over SFTP, NFS, /dav and `filex mount` (internal/space).

A probe that cannot answer returns an error and callers treat that as "cannot measure", never as "no space" — a guard that blocks the work because it could not read a number is worse than no guard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Free

func Free(dir string) (uint64, error)

Free returns the space available to this process on the filesystem holding dir.

Types

type Usage added in v0.60.0

type Usage struct {
	// Total is the size of the filesystem.
	Total uint64
	// Used is what is in use, counted the way df counts it: Total minus every
	// free block, the ones kept back for root included.
	Used uint64
	// Free is what this process could still write. On a filesystem that keeps
	// blocks back for root it is less than Total-Used.
	Free uint64
	// Volume names the filesystem, "" when the platform cannot tell. Two
	// directories with the same Volume are on one disk, so their space is one
	// space, not two.
	Volume string
}

Usage is one filesystem, in bytes.

func Measure added in v0.60.0

func Measure(dir string) (Usage, error)

Measure returns the filesystem holding dir.

Jump to

Keyboard shortcuts

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