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 ¶
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 (*Store) Add ¶
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) Remove ¶
Remove tombstones the root at id (its index) in place. id must address an existing, currently-active entry.
func (*Store) SaveAll ¶
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.