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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 Open ¶ added in v0.18.0
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.