fs

package module
v0.0.0-...-03f2bdc Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package fs implements a Gridwell plugin that projects a host directory tree. Each plugin instance has its own SQLite DB that maps directory paths to stable integer grid IDs and file/dir names to stable integer tile IDs. Positions (x,y,w,h) and well view framing are stored in the plugin DB so they survive restarts.

Index

Constants

View Source
const MenuEntrySearch = "search"

MenuEntrySearch is the entry id fs declares (Tile.menu_entry carries it).

View Source
const SearchParamSchema = `` /* 128-byte string literal not displayed */

searchParamSchema is the #198-subset form the client prompts with on first descent. SearchParamSchema is exported for the v2 fs provider, which declares the same tool (one schema, two declarers until the legacy plugin dies).

Variables

This section is empty.

Functions

func NewFactory

func NewFactory(cfg map[string]string) (gridwellv1.GridwellServer, error)

NewFactory is the compose.Factory for the "fs" kind: cfg is the ONE config vocabulary both process shapes share (the same map a subprocess reads from the spawn env). cfg["db_file"] is the plugin's SQLite DB; cfg["root"] the projected directory.

Types

type Host

type Host interface {
	Remove(path string) error
	RemoveAll(path string) error
}

Host is the destructive side-effect surface. Injected so tests never rm anything on disk. Production wires osHost; tests wire recordHost.

type Plugin

type Plugin struct {
	gridwellv1.UnimplementedGridwellServer
	// contains filtered or unexported fields
}

Plugin implements gridwellv1.GridwellServer for a filesystem source.

func Open

func Open(dbPath string, host Host) (*Plugin, error)

Open opens (or creates) the plugin SQLite DB at dbPath. A nil host uses plain os.Remove/os.RemoveAll.

func (*Plugin) Close

func (p *Plugin) Close() error

Close closes the underlying database.

func (*Plugin) ContentBody

func (p *Plugin) ContentBody(tileIDStr string) (data []byte, mediaType string, err error)

ContentBody returns the descent body for a file tile: real bytes for a renderable/plain file, the metadata summary otherwise (fsfile.Body owns the rule, shared with the v2 provider). Directories, unreadable paths, and unknown ids return empty content rather than an error.

func (*Plugin) CreateTile

CreateTile accepts exactly the tiles fs itself offers: a search well (menu_entry = "search"). Everything else stays refused — fs is a read-only projection; the entry declaration IS the permission.

func (*Plugin) DeleteTile

DeleteTile removes the file or directory from disk (via Host), then drops the tile row from the plugin DB.

func (*Plugin) GetGrid

GetGrid reads the directory for the given grid_id, reconciles tile rows against the current directory contents, and returns the resulting tiles. A missing (definitively gone) directory returns an empty grid without error; a directory that exists but cannot be read this pass returns the stored rows untouched — see the sweep-policy split in the body.

func (*Plugin) GetTile

GetTile returns one tile row by id — cloneAcrossPlugins' first call against the source plugin when a tile is right-dragged into another plugin's grid (issue #171). The row was materialized by the GetGrid that rendered it.

func (*Plugin) GetTilePreview

GetTilePreview serves a JPEG thumbnail for image file tiles. Non-image tiles (and undecodable files) return an empty preview, never an error — the client falls back to the label exactly as it does for a url tile with no capture yet.

func (*Plugin) Info

Info is the whole handshake: identity plus the default root grid (the plugin's configured root directory, resolved to a grid id). No Attach/Detach.

func (*Plugin) PlaceTile

PlaceTile is the single placement writeback: in-grid only (a cross-grid placement would be an on-disk move, which fs does not perform).

func (*Plugin) Probe

Probe checks whether the tile at tile_id still has its backing path on disk.

func (*Plugin) ReadContent

ReadContent streams a file tile's descent body (one chunk; fs bodies are small metadata summaries, version 0 — not version-edited). The one content read.

func (*Plugin) ServeContent

ServeContent streams a file's raw bytes as web content. subpath "" is the tile's own file; a non-empty subpath is a page-relative resource resolved against the file's directory (fsfile.ServeFile owns the confinement).

func (*Plugin) SetReadDir

func (p *Plugin) SetReadDir(f func(dir string) ([]fssource.Entry, error))

SetReadDir overrides the directory reader (a test seam, like the Host deletion surface). nil restores the default fssource.Read.

func (*Plugin) SetRoot

func (p *Plugin) SetRoot(root string)

SetRoot sets the configured default directory Info reports as the root when no path is supplied. Wired by NewFactory from config["root"].

func (*Plugin) SetRootView

SetRootView persists the root grid's viewport (framing audit 2026-08-13: this was silently swallowed before — pan an fs root, gone on re-entry). Framing-class; the server routes here by root_grid_id.

func (*Plugin) SetTile

SetTile persists a directory well's preview framing so descent and ascent restore the same view. fs supports framing only on its directory wells; other kinds/writebacks are not applicable.

func (*Plugin) WriteContent

WriteContent is fs's one write door — and it opens ONLY for the tiles fs itself minted: a search well's params commit (#258), which runs the snapshot and fills the child grid. Everything else stays refused (the projection is read-only; editing files is not fs's business).

Directories

Path Synopsis
cmd
gridwell-plugin-fs command
gridwell-fs is the out-of-process filesystem plugin binary.
gridwell-fs is the out-of-process filesystem plugin binary.
gridwell-provider-fs command
gridwell-provider-fs — the v2 fs content provider binary (docs/v2-design.md §5): a stateless projection of a directory tree serving contentprovider.v1.
gridwell-provider-fs — the v2 fs content provider binary (docs/v2-design.md §5): a stateless projection of a directory tree serving contentprovider.v1.
Package fsfile is the PURE core of the fs projection: every derivation from a filename or file bytes, with no database and no tile ids.
Package fsfile is the PURE core of the fs projection: every derivation from a filename or file bytes, with no database and no tile ids.
Package fssource reads a host directory and projects its contents into the abstract entries an fs-grid is reconciled against.
Package fssource reads a host directory and projects its contents into the abstract entries an fs-grid is reconciled against.
Package provider is the v2 fs CONTENT PROVIDER (docs/v2-design.md §5): the stateless projection of a directory tree.
Package provider is the v2 fs CONTENT PROVIDER (docs/v2-design.md §5): the stateless projection of a directory tree.
Package trash moves host files into the freedesktop.org "home trash" instead of unlinking them, so discarding a file (or a directory) through Gridwell is recoverable rather than an irreversible rm -rf.
Package trash moves host files into the freedesktop.org "home trash" instead of unlinking them, so discarding a file (or a directory) through Gridwell is recoverable rather than an irreversible rm -rf.

Jump to

Keyboard shortcuts

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