Documentation
¶
Overview ¶
Package serve runs the dscan engine as a headless JSON loop over stdio, for the Electron GUI. One JSON object per line in each direction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run reads newline-delimited JSON requests from in and writes JSON events to out. It is the GUI sidecar entry point (`dscan serve`). Requests are read on a separate goroutine so a `cancel` arriving mid-scan is acted on immediately; scan and clean run asynchronously. Run returns once in is exhausted and all in-flight work has drained.
Types ¶
type AppDTO ¶ added in v0.6.0
type AppDTO struct {
ID string `json:"id"`
Name string `json:"name"`
BundleID string `json:"bundleId"`
Path string `json:"path"`
Bytes int64 `json:"bytes"`
Arch string `json:"arch"` // intel|appleSilicon|universal|unknown
}
AppDTO is the wire form of an apps.App.
type Event ¶
type Event struct {
Event string `json:"event"`
Tab string `json:"tab,omitempty"` // routes the event to a GUI tab slice (empty = not tab-scoped)
Disk *diskInfo `json:"disk,omitempty"`
Item *ItemDTO `json:"item,omitempty"`
Scanned int `json:"scanned,omitempty"`
Phase string `json:"phase,omitempty"`
Bytes int64 `json:"bytes,omitempty"`
Path string `json:"path,omitempty"`
Reclaimable int64 `json:"reclaimable,omitempty"`
Freed int64 `json:"freed,omitempty"`
Trashed int64 `json:"trashed,omitempty"`
Errors []string `json:"errors,omitempty"`
Message string `json:"message,omitempty"`
Node *engine.Node `json:"node,omitempty"` // tree: disk-map root
App *AppDTO `json:"app,omitempty"`
Host *hostInfo `json:"host,omitempty"`
Leftovers []leftoverDTO `json:"leftovers,omitempty"`
}
Event is an outbound message (sidecar → main stdout). Only the fields relevant to the event are populated; the rest are omitted.
type ItemDTO ¶
type ItemDTO struct {
ID string `json:"id"`
Path string `json:"path"`
Label string `json:"label"`
Bytes int64 `json:"bytes"`
Category string `json:"category"`
Tier string `json:"tier"` // SAFE|REVIEW|KEEP
Method string `json:"method"` // remove|trash|command
Source string `json:"source"` // catalog|heuristic
Selectable bool `json:"selectable"`
Modified int64 `json:"modified,omitempty"`
Kind string `json:"kind,omitempty"`
Command []string `json:"command,omitempty"`
}
ItemDTO is the wire form of a rules.Item (string enums, stable id).
type Request ¶
type Request struct {
Cmd string `json:"cmd"` // scan|map|clean|trash|cancel
Tab string `json:"tab"` // cleanup|projects|map|apps: which tab the command targets
Kind string `json:"kind"` // scan: "caches" (default) | "projects"
Root string `json:"root"` // scan/map: folder to search
Path string `json:"path"` // trash: path to move to Trash
Excludes []string `json:"excludes"` // scan/map: skip these path prefixes
System bool `json:"system"` // scan: include system dirs
IDs []string `json:"ids"` // clean: which items
DryRun bool `json:"dryRun"` // clean: preview only
KillLockers bool `json:"killLockers"` // clean: SIGTERM processes holding the paths first
Paths []string `json:"paths"` // uninstall: paths to move to Trash
}
Request is a command from the GUI (main → sidecar stdin).