types

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CategorySummary

type CategorySummary struct {
	Category string    `json:"category"`
	Size     int64     `json:"size"`
	Files    int       `json:"files"`
	Risk     RiskLevel `json:"risk"`
	Items    []Item    `json:"items"`
}

CategorySummary aggregates every item a scanner found under one category name. TUI rows and the `scan` CLI summary both render from this struct.

type CleanResult

type CleanResult struct {
	RestoreID string `json:"restore_id"`
	Freed     int64  `json:"freed"`
	Files     int    `json:"files"`
	Skipped   int    `json:"skipped"`
	Cancelled bool   `json:"cancelled,omitempty"`
}

CleanResult summarises one clean operation: bytes freed, file count, items skipped (e.g. locked or out of policy), and the restore ID for the quarantine batch, or empty when quarantine was disabled.

type Item

type Item struct {
	Category string    `json:"category"`
	Path     string    `json:"path"`
	Size     int64     `json:"size"`
	Risk     RiskLevel `json:"risk"`
	Selected bool      `json:"selected"`
}

Item is a single cleanup candidate produced by a scanner. It points at one on-disk path and remembers its category, size, and risk for downstream filtering.

type Manifest

type Manifest struct {
	ID         string         `json:"id"`
	CreatedAt  time.Time      `json:"created_at"`
	Label      string         `json:"label"`
	Categories []string       `json:"categories,omitempty"`
	TotalSize  int64          `json:"total_size"`
	Files      int            `json:"files"`
	Items      []ManifestItem `json:"items"`
}

Manifest is the per-cleanup record persisted inside the quarantine directory. It is the only authoritative source for what a restore has to put back, so it must be written atomically and read on every restore attempt.

type ManifestItem

type ManifestItem struct {
	Original    string `json:"original"`
	Quarantined string `json:"quarantined"`
	Size        int64  `json:"size"`
}

ManifestItem pairs a file's original path with the path it now has inside the quarantine dir, so a restore can move the bytes back without ambiguity.

type Progress added in v1.10.0

type Progress struct {
	Stage      string
	Processed  int
	Total      int
	Bytes      int64
	TotalBytes int64
	StartedAt  time.Time
}

Progress carries progress info for long-running operations. Stage is "scanning" or "cleaning". Callers compute ETA/throughput from StartedAt and the current counts.

func (Progress) ETA added in v1.10.0

func (p Progress) ETA() time.Duration

ETA returns the estimated time remaining, or zero when it cannot be computed.

func (Progress) Elapsed added in v1.10.0

func (p Progress) Elapsed() time.Duration

Elapsed returns the wall-clock duration since the operation started.

func (Progress) FormatETA added in v1.10.0

func (p Progress) FormatETA() string

FormatETA returns a human-readable ETA string (e.g. "1m30s") or empty string.

func (Progress) FormatThroughput added in v1.10.0

func (p Progress) FormatThroughput() string

FormatThroughput returns a human-readable throughput string (e.g. "12.3 MB/s").

func (Progress) Percent added in v1.10.0

func (p Progress) Percent() int

Percent returns the completion percentage, clamped to [0, 100].

func (Progress) ThroughputMBps added in v1.10.0

func (p Progress) ThroughputMBps() float64

ThroughputMBps returns megabytes per second, or 0 when there is no data yet.

type ProgressFn added in v1.10.0

type ProgressFn func(Progress)

ProgressFn is a callback for progress updates, throttled by the callee to ~250 ms so the consumer does not need its own rate-limiting.

type ReportData

type ReportData struct {
	Timestamp time.Time    `json:"timestamp"`
	Result    ScanResult   `json:"result"`
	Cleaned   *CleanResult `json:"cleaned,omitempty"`
}

ReportData bundles a scan with the optional clean result so a single JSON report can answer both "what was found" and "what was removed".

type RiskLevel

type RiskLevel string

RiskLevel expresses how dangerous it is to delete a file. It drives the UI color and gates which items the `clean` command refuses to touch without --danger.

const (
	RiskSafe   RiskLevel = "safe"
	RiskReview RiskLevel = "review"
	RiskDanger RiskLevel = "danger"
)

type ScanResult

type ScanResult struct {
	Categories []CategorySummary `json:"categories"`
	TotalSize  int64             `json:"total_size"`
	SafeSize   int64             `json:"safe_size"`
	ReviewSize int64             `json:"review_size"`
	DangerSize int64             `json:"danger_size"`
}

ScanResult is the output of a full scan across every enabled category. The Safe/Review/Danger size fields are pre-computed so the TUI and the report CLI can render risk totals without re-walking the categories.

Jump to

Keyboard shortcuts

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