Documentation
¶
Index ¶
- Constants
- func CategoryNames(categories []Category) []string
- func CategoryOrder() []string
- func EnsureDirs() error
- func GetDocumentsDir() string
- func GetDownloadsDir() string
- func GetLogsDir() string
- func GetMusicDir() string
- func GetPicturesDir() string
- func GetRuntimeDir() string
- func GetSettingsMetadata() map[string][]SettingMeta
- func GetSettingsPath() string
- func GetStateDir() string
- func GetSurgeDir() string
- func GetVideosDir() string
- func ResolveCategoryPath(cat *Category, defaultDownloadDir string) string
- func SaveSettings(s *Settings) error
- type Category
- type GeneralSettings
- type NetworkSettings
- type PerformanceSettings
- type RuntimeConfig
- type SettingMeta
- type Settings
Constants ¶
const ( ThemeAdaptive = 0 ThemeLight = 1 ThemeDark = 2 )
const ( KB = 1 << 10 MB = 1 << 20 )
Variables ¶
This section is empty.
Functions ¶
func CategoryNames ¶
CategoryNames returns a slice of category names.
func CategoryOrder ¶
func CategoryOrder() []string
CategoryOrder returns the order of categories for UI tabs.
func GetDocumentsDir ¶
func GetDocumentsDir() string
func GetDownloadsDir ¶
func GetDownloadsDir() string
func GetMusicDir ¶
func GetMusicDir() string
func GetPicturesDir ¶
func GetPicturesDir() string
func GetRuntimeDir ¶
func GetRuntimeDir() string
func GetSettingsMetadata ¶
func GetSettingsMetadata() map[string][]SettingMeta
GetSettingsMetadata returns metadata for all settings organized by category.
func GetSettingsPath ¶
func GetSettingsPath() string
GetSettingsPath returns the path to the settings JSON file.
func GetStateDir ¶
func GetStateDir() string
func GetSurgeDir ¶
func GetSurgeDir() string
GetSurgeDir returns the directory for configuration files (settings.json). Linux: $XDG_CONFIG_HOME/surge or ~/.config/surge macOS: ~/Library/Application Support/surge Windows: %APPDATA%/surge
func GetVideosDir ¶
func GetVideosDir() string
func ResolveCategoryPath ¶
ResolveCategoryPath returns the Path of a category.
func SaveSettings ¶
SaveSettings saves settings to disk atomically.
Types ¶
type Category ¶
type Category struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Pattern string `json:"pattern"`
Path string `json:"path"`
}
Category defines a download category for auto-sorting.
func DefaultCategories ¶
func DefaultCategories() []Category
DefaultCategories returns the default set of download categories.
func GetCategoryForFile ¶
GetCategoryForFile returns the last matching category so user-added rules can override broader defaults that appear earlier in the list.
type GeneralSettings ¶
type GeneralSettings struct {
DefaultDownloadDir string `json:"default_download_dir"`
WarnOnDuplicate bool `json:"warn_on_duplicate"`
DownloadCompleteNotification bool `json:"download_complete_notification"`
AllowRemoteOpenActions bool `json:"allow_remote_open_actions"`
ExtensionPrompt bool `json:"extension_prompt"`
AutoResume bool `json:"auto_resume"`
SkipUpdateCheck bool `json:"skip_update_check"`
CategoryEnabled bool `json:"category_enabled"`
Categories []Category `json:"categories"`
ClipboardMonitor bool `json:"clipboard_monitor"`
Theme int `json:"theme"`
LogRetentionCount int `json:"log_retention_count"`
}
GeneralSettings contains application behavior settings.
type NetworkSettings ¶
type NetworkSettings struct {
MaxConnectionsPerHost int `json:"max_connections_per_host"`
MaxConcurrentDownloads int `json:"max_concurrent_downloads"`
UserAgent string `json:"user_agent"`
ProxyURL string `json:"proxy_url"`
SequentialDownload bool `json:"sequential_download"`
MinChunkSize int64 `json:"min_chunk_size"`
WorkerBufferSize int `json:"worker_buffer_size"`
}
NetworkSettings contains network connection parameters.
type PerformanceSettings ¶
type PerformanceSettings struct {
MaxTaskRetries int `json:"max_task_retries"`
SlowWorkerThreshold float64 `json:"slow_worker_threshold"`
SlowWorkerGracePeriod time.Duration `json:"slow_worker_grace_period"`
StallTimeout time.Duration `json:"stall_timeout"`
SpeedEmaAlpha float64 `json:"speed_ema_alpha"`
}
PerformanceSettings contains performance tuning parameters.
type RuntimeConfig ¶
type RuntimeConfig struct {
MaxConnectionsPerHost int
UserAgent string
ProxyURL string
SequentialDownload bool
MinChunkSize int64
WorkerBufferSize int
MaxTaskRetries int
SlowWorkerThreshold float64
SlowWorkerGracePeriod time.Duration
StallTimeout time.Duration
SpeedEmaAlpha float64
}
ToRuntimeConfig converts Settings to a downloader RuntimeConfig This is used to pass user settings to the download engine
type SettingMeta ¶
type SettingMeta struct {
Key string // JSON key name
Label string // Human-readable label
Description string // Help text displayed in right pane
Type string // "string", "int", "int64", "bool", "duration", "float64"
}
SettingMeta provides metadata for a single setting (for UI rendering).
type Settings ¶
type Settings struct {
General GeneralSettings `json:"general"`
Network NetworkSettings `json:"network"`
Performance PerformanceSettings `json:"performance"`
}
Settings holds all user-configurable application settings organized by category.
func DefaultSettings ¶
func DefaultSettings() *Settings
DefaultSettings returns a new Settings instance with sensible defaults.
func LoadSettings ¶
LoadSettings loads settings from disk. Returns defaults if file doesn't exist or if the JSON is corrupt, so the application can always start.
func (*Settings) ToRuntimeConfig ¶
func (s *Settings) ToRuntimeConfig() *RuntimeConfig
ToRuntimeConfig creates a RuntimeConfig from user Settings