rundir

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rundir finds komando's own per-user folder for short-lived private files (a restore's checked copy, the approval debug log), never the shared temp folder, where another user may have planted a name or a link.

Index

Constants

View Source
const Stale = 10 * time.Minute

Stale is the age of a leftover Sweep removes: a run that was killed outright (SIGKILL, a power cut) could not remove its own.

Variables

View Source
var Base = func() (string, error) {
	home, err := store.AccountHome()
	if err != nil {
		if home, err = store.UserHome(); err != nil {
			return "", err
		}
	}
	return inHome(runtime.GOOS, home), nil
}

Base is where the folder goes; tests point it elsewhere. It lies in the account's home folder from the system's user database (store.AccountHome), for every caller: no variable moves it, not HOME or USERPROFILE and not XDG_RUNTIME_DIR, XDG_STATE_HOME or LOCALAPPDATA, whether set in front of komando or in front of a shell that runs it. The folder holds a restore's checked copy and the approval window's text. Only when the user database has no entry for the account (a container's made-up uid) is it store.UserHome; the cli then stops an AI agent's commands until a person allows it (guardHome).

Functions

func Append

func Append(dir, name string) (*os.File, error)

Append opens NAME in dir, a folder Dir checked, for adding to its end, 0600 when new. A link or anything but a file is refused (openFile, per OS), and a file others may open is narrowed to 0600.

func Check

func Check(dir string) error

Check refuses dir unless it is a folder (Lstat: a link is not followed) of this user that only this user may open (0700).

func Create

func Create(dir, name string) (*os.File, error)

Create makes a new file NAME-<random>.tmp in dir, opened for reading and writing: an existing name or link is never opened, and no one else may change it (create, per OS).

func Dir

func Dir() (string, error)

Dir returns the folder, made 0700 when missing, after Check: a link, a file, another user's folder or one others may open is refused.

func Free

func Free(dir string) (uint64, error)

Free is the space in dir's file system this user may write.

func Open added in v0.18.0

func Open(dir, name string) (*os.File, error)

Open opens NAME in dir, a folder Dir checked, for reading and writing (a lock file), with Append's rules.

func Sweep

func Sweep(dir, name string)

Sweep removes NAME-*.tmp leftovers older than Stale from dir, a folder Dir checked (only this user can write there). Links are removed, never followed. On Unix a file another run still reads goes too: it reads through its open descriptor, which keeps the bytes until it closes it. On Windows that file cannot be removed; it goes when that run closes it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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