Help us shape the future of Go! Take the 2026 Go Developer Survey

models

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollisionPolicy

type CollisionPolicy string

CollisionPolicy defines how to handle existing destination files.

const (
	CollisionSkip    CollisionPolicy = "skip"
	CollisionRename  CollisionPolicy = "rename"
	CollisionReplace CollisionPolicy = "replace"
	CollisionAbort   CollisionPolicy = "abort"
)

type Condition

type Condition struct {
	Field    TargetField `json:"field" toml:"field"`
	Operator Operator    `json:"operator" toml:"operator"`
	Value    string      `json:"value" toml:"value"`
}

Condition defines an evaluation rule for a file.

type File

type File struct {
	Path            string            `json:"path"`      // Absolute or full path
	RelPath         string            `json:"rel_path"`  // Relative path from chest root
	Name            string            `json:"name"`      // Filename including extension
	Extension       string            `json:"extension"` // Lowercase extension without dot (e.g. "mp4", "png")
	Format          string            `json:"format,omitempty"`
	Metadata        map[string]string `json:"metadata,omitempty"`
	Size            int64             `json:"size"`     // Size in bytes
	ModTime         time.Time         `json:"mod_time"` // Last modification time
	TakenDate       *time.Time        `json:"taken_date,omitempty"`
	TakenDateSource string            `json:"taken_date_source,omitempty"`
	IsDir           bool              `json:"is_dir"`    // Is directory
	IsHidden        bool              `json:"is_hidden"` // Is hidden or system file
	MIMEType        string            `json:"mime_type"` // MIME type (if available)
	Category        string            `json:"category"`  // High-level category (Image, Video, etc.)
}

File represents a file inspected by CHEST.

type FileMetadata added in v0.4.1

type FileMetadata struct {
	Format     string            `json:"format,omitempty"`      // e.g. "CR3", "PhotoshopDocument"
	MIMEType   string            `json:"mime_type,omitempty"`   // e.g. "image/x-canon-cr3"
	Category   string            `json:"category,omitempty"`    // e.g. "Image", "Video", "Document"
	TakenDate  *time.Time        `json:"taken_date,omitempty"`  // Embedded capture/creation date
	DateSource string            `json:"date_source,omitempty"` // Label describing where TakenDate came from
	Fields     map[string]string `json:"fields,omitempty"`      // Extra metadata key/value pairs
}

FileMetadata is the enriched metadata a metadata plugin may return for a sample. Every field is optional: empty strings and a zero TakenDate leave the built-in detection untouched. Fields merge into the file record's metadata map and become available to rule conditions and the index.

func (FileMetadata) HasContent added in v0.4.1

func (m FileMetadata) HasContent() bool

HasContent reports whether any enrichment was actually produced. Empty results and blank-only field values let the host skip work entirely.

type FileSample added in v0.4.1

type FileSample struct {
	Path      string `json:"path"`                // Absolute path on disk
	Name      string `json:"name"`                // Filename including extension
	Extension string `json:"extension"`           // Lowercase extension without dot
	Format    string `json:"format,omitempty"`    // Format detected by built-in extractors (may be empty)
	MIMEType  string `json:"mime_type,omitempty"` // MIME type detected by built-in extractors (may be empty)
	Size      int64  `json:"size"`                // Size in bytes
	Head      []byte `json:"head,omitempty"`      // First bytes of file content (bounded)
	Tail      []byte `json:"tail,omitempty"`      // Last bytes of file content (bounded)
}

FileSample is the bounded view of a file sent to metadata plugins for inspection. Head/Tail carry the first and last few KiB of file content so plugins can sniff signatures without reading the whole file over RPC.

type HistoryEntry

type HistoryEntry struct {
	ID         int                `json:"id"`
	Timestamp  time.Time          `json:"timestamp"`
	Directory  string             `json:"directory"`
	Operations []HistoryOperation `json:"operations"`
	FilesCount int                `json:"files_count"`
	// Status is one of: Complete (all ops ok), Partial (some ops failed but
	// some moved), Failed (nothing moved), Undone (rolled back).
	Status string `json:"status"`
	// Errors holds the per-file failures that made Status Partial or Failed.
	Errors []string `json:"errors,omitempty"`
}

HistoryEntry stores a batch organization run.

type HistoryOperation

type HistoryOperation struct {
	OriginalSource string `json:"original_source"`
	Destination    string `json:"destination"`
	Reason         string `json:"reason"`
}

HistoryOperation stores an individual reversed/applied file move.

type Operation

type Operation struct {
	Source      string          `json:"source"`
	Destination string          `json:"destination"`
	Reason      string          `json:"reason"`
	Action      CollisionPolicy `json:"action"` // what will happen if collision exists
	IsCollision bool            `json:"is_collision"`
}

Operation represents a single proposed or executed file move.

type Operator

type Operator string

Operator defines comparison operator.

const (
	OpEqual       Operator = "="
	OpNotEqual    Operator = "!="
	OpGreaterThan Operator = ">"
	OpLessThan    Operator = "<"
	OpGreaterEq   Operator = ">="
	OpLessEq      Operator = "<="
	OpContains    Operator = "contains"
	OpStartsWith  Operator = "starts_with"
	OpEndsWith    Operator = "ends_with"
	OpGlob        Operator = "glob"
	OpRegex       Operator = "regex"
)

type Plan

type Plan struct {
	RootPath        string         `json:"root_path"`
	Operations      []Operation    `json:"operations"`
	FoldersToCreate []string       `json:"folders_to_create"`
	Conflicts       []PlanConflict `json:"conflicts,omitempty"`
	TotalFiles      int            `json:"total_files"`
	SkippedFiles    int            `json:"skipped_files"`
}

Plan represents the complete set of proposed filesystem changes.

type PlanConflict added in v0.7.0

type PlanConflict struct {
	Target     string   `json:"target"`     // path the conflicting file ended up at
	Sources    []string `json:"sources"`    // first claimant, then the conflicting file
	Resolution string   `json:"resolution"` // what happened to the second file
}

PlanConflict records a destination that more than one source resolved to within the same plan, together with how the second claim was handled.

type Rule

type Rule struct {
	Name        string      `json:"name" toml:"name"`
	Priority    int         `json:"priority" toml:"priority"`
	Conditions  []Condition `json:"conditions" toml:"conditions"`
	Destination string      `json:"destination" toml:"destination"`
	Extensions  []string    `json:"extensions,omitempty" toml:"extensions,omitempty"` // convenience helper in presets
	MinSize     string      `json:"min_size,omitempty" toml:"min_size,omitempty"`     // convenience helper in presets
	MaxSize     string      `json:"max_size,omitempty" toml:"max_size,omitempty"`     // convenience helper in presets
	Type        string      `json:"type,omitempty" toml:"type,omitempty"`             // convenience helper in presets
}

Rule defines sorting rule.

type TargetField

type TargetField string

TargetField defines what attribute of the file the condition inspects.

const (
	FieldExtension TargetField = "extension"
	FieldFormat    TargetField = "format"
	FieldType      TargetField = "type"
	FieldSize      TargetField = "size"
	FieldName      TargetField = "name"
	FieldDate      TargetField = "date"
	FieldModTime   TargetField = "mod_time"
	FieldTakenDate TargetField = "taken_date"
	FieldMIME      TargetField = "mime"
)

Jump to

Keyboard shortcuts

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