Documentation
¶
Overview ¶
Package disk keeps patty's clone cache within a byte budget and off the last free gigabytes of the drive.
Index ¶
Constants ¶
const ( KiB int64 = 1 << 10 MiB int64 = 1 << 20 GiB int64 = 1 << 30 TiB int64 = 1 << 40 )
Variables ¶
var ErrBudget = errors.New("disk budget")
ErrBudget is returned when a repository does not fit the disk budget.
Functions ¶
func FormatSize ¶
FormatSize renders bytes with a binary unit and one decimal.
func Free ¶
Free returns the bytes available to an unprivileged user on the filesystem holding path.
Types ¶
type Cache ¶
type Cache struct {
Dir string
// MaxBytes caps the total size of all mirrors in the cache.
MaxBytes int64
// MinFree is the free space that must remain on the drive after a clone.
MinFree int64
// contains filtered or unexported fields
}
Cache is the directory patty mirrors repositories into. Mirrors live at <Dir>/<host>/<owner>/<repo>.git.
func (*Cache) Admit ¶
Admit makes room for a repository of the estimated size and marks its path as in use so concurrent evictions leave it alone. It evicts the least recently used mirrors first and fails with ErrBudget when the repository still would not fit the budget or would push the drive below MinFree. Call Release when done with the path.