roots

package
v0.0.0-...-b43479a Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package roots persists Eta's exposed root directories as a stable, append-only list. A root's position in this list is its ID — handleRoots in main.go has returned {id: index, name} to the browser since before this package existed, and every persisted reference to a root (a desktop shortcut, a window's state, a transfer job) is that same index. Removing a root by splicing it out of a slice would silently repoint every one of those references at whatever root happened to shift into its old position; the danger is not merely a renumbering, it is a Copy or Delete quietly landing in the wrong directory.

So removal here never deletes or renumbers a slot. It sets Removed on the entry in place. New roots are only ever appended, keeping every existing index meaningful for the life of this config file — a request naming a removed root's old index fails cleanly ("unknown root"), never silently resolves to a directory that took its place, because nothing ever takes its place.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

Types

type Root

type Root struct {
	Name    string `json:"name"`
	Path    string `json:"path"`
	Removed bool   `json:"removed,omitempty"`
}

Root is Name/Path, matching the shape main.go already built in memory from -root flags, plus Removed for a tombstoned slot.

type Store

type Store struct {
	// contains filtered or unexported fields
}

func New

func New(path string) *Store

func (*Store) Add

func (s *Store) Add(name, path string) ([]Root, error)

Add appends a new root, or reactivates a removed one at its original index if the same path was removed before — re-adding a root you just removed should not create a second entry for it, and reusing the old slot rather than appending keeps the list from growing tombstones for what is really the same root toggled off and back on.

func (*Store) Load

func (s *Store) Load() ([]Root, error)

func (*Store) Remove

func (s *Store) Remove(id int) ([]Root, error)

Remove tombstones the root at id (its index) in place. id must address an existing, currently-active entry.

func (*Store) SaveAll

func (s *Store) SaveAll(list []Root) error

SaveAll overwrites the whole list, position for position. Used once, at startup, to seed the file from -root flags when it does not exist yet — every later mutation goes through Add/Remove instead, so a caller cannot accidentally renumber an established list by saving a stale copy of it.

Jump to

Keyboard shortcuts

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