Documentation
¶
Overview ¶
Package filelock takes locks that upstream pi can interoperate with, and keeps the JSON documents those locks guard.
Upstream guards its shared state files with npm proper-lockfile, which creates the lock as a DIRECTORY via mkdir and refreshes its mtime while held. A POSIX flock on the same path leaves a zero-byte regular file behind instead, and proper-lockfile never treats a plain file as stale, so it then fails with EEXIST forever. One orb write is enough to wedge the TypeScript runtime permanently. Every path both runtimes touch must lock through here.
Index ¶
Constants ¶
const ( // AsyncStale is the window upstream's async auth lock refreshes against // (every 15 s), so a live upstream lock is never reclaimed. AsyncStale = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func GroupOrOtherAccess ¶ added in v0.19.1
GroupOrOtherAccess reports POSIX group or other permission bits. Windows has none (Go reports 0666/0777 there); the profile directory's ACL is what keeps private state private on that platform.
Types ¶
type File ¶ added in v0.19.1
type File struct {
Path string
Perm os.FileMode
// Stale is how long a dead holder's lock takes to expire: AsyncStale for
// auth.json, whose upstream lock heartbeats; 10 s when zero.
Stale time.Duration
// Atomic replaces the file through a renamed temporary (WriteFile).
// Otherwise it is rewritten in place, as upstream writes auth, settings
// and trust files, which keeps their owner, umask, symlinks and
// single-file bind mounts; a private Perm is then enforced on the file.
Atomic bool
}
File is a Document kept in the file at Path. Update holds the lock upstream takes on the same path; Read takes no lock, so it can nest inside an Update and never blocks on one.