config

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureDir

func EnsureDir(path string, perm fs.FileMode) error

Ensure paths that should exist (optional helper for future use)

Types

type AppPlacement

type AppPlacement struct {
	Base  string            `yaml:"base"`
	Paths map[string]string `yaml:"paths"`
}

type Backoff

type Backoff struct {
	MinMS  int  `yaml:"min_ms"`
	MaxMS  int  `yaml:"max_ms"`
	Jitter bool `yaml:"jitter"`
}

type ClassifierConfig

type ClassifierConfig struct {
	Rules []ClassifierRule `yaml:"rules"`
}

type ClassifierRule

type ClassifierRule struct {
	Regex string `yaml:"regex"`
	Type  string `yaml:"type"`
}

type Concurrency

type Concurrency struct {
	GlobalFiles     int     `yaml:"global_files"`
	PerFileChunks   int     `yaml:"per_file_chunks"`
	PerHostRequests int     `yaml:"per_host_requests"`
	ChunkSizeMB     int     `yaml:"chunk_size_mb"`
	MaxRetries      int     `yaml:"max_retries"`
	Backoff         Backoff `yaml:"backoff"`
}

type Config

type Config struct {
	Version     int              `yaml:"version"`
	General     General          `yaml:"general"`
	Network     Network          `yaml:"network"`
	Concurrency Concurrency      `yaml:"concurrency"`
	Sources     Sources          `yaml:"sources"`
	Resolver    ResolverConf     `yaml:"resolver"`
	Placement   Placement        `yaml:"placement"`
	Classifier  ClassifierConfig `yaml:"classifier"`
	Logging     Logging          `yaml:"logging"`
	Metrics     Metrics          `yaml:"metrics"`
	Validation  Validation       `yaml:"validation"`
	UI          UIOptions        `yaml:"ui"`
}

Config mirrors the YAML schema. All values should be supplied via YAML; we avoid hard-coded defaults. Minimal validation occurs in Validate().

func Load

func Load(path string) (*Config, error)

Load reads, parses, expands, and validates a YAML config file.

func (*Config) Validate

func (c *Config) Validate() error

type General

type General struct {
	DataRoot       string `yaml:"data_root"`
	DownloadRoot   string `yaml:"download_root"`
	PartialsRoot   string `yaml:"partials_root"`
	PlacementMode  string `yaml:"placement_mode"` // symlink | hardlink | copy
	Quarantine     bool   `yaml:"quarantine"`
	AllowOverwrite bool   `yaml:"allow_overwrite"`
	DryRun         bool   `yaml:"dry_run"`
	// Downloads behavior
	StagePartials      bool `yaml:"stage_partials"`        // if true (default), write .part files under download_root/.parts or partials_root if set
	AlwaysNoResume     bool `yaml:"always_no_resume"`      // if true, do not resume partials unless overridden on CLI
	AutoRecoverOnStart bool `yaml:"auto_recover_on_start"` // if true, TUI auto-resumes previously running downloads on startup
}

type LogFile

type LogFile struct {
	Enabled      bool   `yaml:"enabled"`
	Path         string `yaml:"path"`
	MaxMegabytes int    `yaml:"max_megabytes"`
	MaxBackups   int    `yaml:"max_backups"`
	MaxAgeDays   int    `yaml:"max_age_days"`
}

type Logging

type Logging struct {
	Level  string  `yaml:"level"`  // debug|info|warn|error
	Format string  `yaml:"format"` // human|json
	File   LogFile `yaml:"file"`
}

type MappingRule

type MappingRule struct {
	Match   string          `yaml:"match"`
	Targets []MappingTarget `yaml:"targets"`
}

type MappingTarget

type MappingTarget struct {
	App     string `yaml:"app"`
	PathKey string `yaml:"path_key"`
}

type Metrics

type Metrics struct {
	PrometheusTextfile PromTextfile `yaml:"prometheus_textfile"`
}

type Network

type Network struct {
	TimeoutSeconds int    `yaml:"timeout_seconds"`
	MaxRedirects   int    `yaml:"max_redirects"`
	TLSVerify      bool   `yaml:"tls_verify"`
	UserAgent      string `yaml:"user_agent"`
	// When true, respect HTTP 429 Retry-After for retries (chunked and single fallback)
	RetryOnRateLimit bool `yaml:"retry_on_rate_limit"`
	// Cap the wait derived from Retry-After to avoid excessively long sleeps (seconds)
	RateLimitMaxDelaySeconds int `yaml:"rate_limit_max_delay_seconds"`
	// When true, skip the early HEAD/0-0 auth preflight in CLI and TUI v2
	DisableAuthPreflight bool `yaml:"disable_auth_preflight"`
}

type Placement

type Placement struct {
	Apps    map[string]AppPlacement `yaml:"apps"`
	Mapping []MappingRule           `yaml:"mapping"`
}

type PromTextfile

type PromTextfile struct {
	Enabled bool   `yaml:"enabled"`
	Path    string `yaml:"path"`
}

type ResolverConf

type ResolverConf struct {
	CacheTTLHours int `yaml:"cache_ttl_hours"`
}

type SourceNaming

type SourceNaming struct {
	// Pattern controls default filename generation when dest is omitted.
	// Supported tokens vary by resolver:
	// - CivitAI: {model_name}, {version_name}, {version_id}, {file_name}, {file_type}
	// - HuggingFace: {owner}, {repo}, {path}, {rev}, {file_name}
	Pattern string `yaml:"pattern"`
}

type SourceWithToken

type SourceWithToken struct {
	Enabled  bool         `yaml:"enabled"`
	TokenEnv string       `yaml:"token_env"`
	Naming   SourceNaming `yaml:"naming"`
}

type Sources

type Sources struct {
	HuggingFace SourceWithToken `yaml:"huggingface"`
	CivitAI     SourceWithToken `yaml:"civitai"`
}

type UIOptions

type UIOptions struct {
	// RefreshHz controls the TUI refresh frequency (ticks per second). If 0, defaults to 1.
	// Values above 10 are clamped to 10 to avoid excessive CPU usage.
	RefreshHz int `yaml:"refresh_hz"`
	// ShowURL sets the initial table mode to show URL instead of DEST in the last column.
	// Deprecated in favor of ColumnMode but still honored if ColumnMode is empty.
	ShowURL bool `yaml:"show_url"`
	// ColumnMode controls which field is shown in the last column: dest | url | host
	ColumnMode string `yaml:"column_mode"`
	// Compact reduces columns in the v2 table (hides SPEED/THR) for a denser view.
	Compact bool `yaml:"compact"`
	// Theme allows selecting a theme by name from a predefined set (optional).
	Theme string `yaml:"theme"`
}

type Validation

type Validation struct {
	RequireSHA256                      bool `yaml:"require_sha256"`
	AcceptMD5SHA1IfProvided            bool `yaml:"accept_md5_sha1_if_provided"`
	SafetensorsDeepVerifyAfterDownload bool `yaml:"safetensors_deep_verify_after_download"`
}

Jump to

Keyboard shortcuts

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