persist

package
v1.56.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanBuffers

func CleanBuffers(dir string, activePaneIDs []string) error

CleanBuffers removes buffer files for panes that no longer exist.

func DeleteNotes

func DeleteNotes(dir, paneID string) error

DeleteNotes removes a pane's notes file. Missing files are not an error.

func Load

func Load(path string) (map[string]any, error)

Load reads workspace state from a JSON file. Falls back to path.bak if the primary file is missing or corrupt. Returns nil, nil if neither file exists (fresh workspace).

func LoadBuffer

func LoadBuffer(dir, paneID string) ([]byte, error)

LoadBuffer reads a pane's saved output buffer from disk. Returns nil, nil if the file doesn't exist.

func LoadNotes

func LoadNotes(dir, paneID string) (string, error)

LoadNotes reads the notes content for a pane from dir. Returns an empty string when no notes file exists, or when the notes directory is missing/not yet created. Refuses to follow symlinks so an attacker who plants a symlink in the notes directory cannot trick the editor into reading another file.

func NotesFileName

func NotesFileName(paneID string) (string, error)

NotesFileName returns the sanitized filename for a pane's notes file. The pane ID must not contain any path separators, path traversal tokens, Windows reserved device names, or other special characters.

func NotesPath

func NotesPath(dir, paneID string) (string, error)

NotesPath returns the absolute path to a pane's notes file within dir.

func Save

func Save(path string, state map[string]any) error

Save writes workspace state as JSON to path atomically. The previous file is renamed to path.bak for rollback.

func SaveAllBuffers

func SaveAllBuffers(dir string, buffers map[string][]byte) error

SaveAllBuffers writes all pane buffers to disk (best-effort). Returns the first error encountered but continues saving remaining buffers.

func SaveBuffer

func SaveBuffer(dir, paneID string, data []byte) error

SaveBuffer writes a pane's output buffer to a file atomically.

func SaveNotes

func SaveNotes(dir, paneID, content string) error

SaveNotes writes notes content atomically for a pane. Creates the notes directory if missing. Uses a unique temp file + rename pattern so readers never observe a partial write and concurrent writers do not race on the same temp filename.

Types

This section is empty.

Jump to

Keyboard shortcuts

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