backend

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIQueueUploadRequest added in v0.0.30

type APIQueueUploadRequest struct {
	File              string `json:"file"`
	RelativePath      string `json:"relative_path"`
	Priority          int    `json:"priority,omitempty"`
	DeleteAfterUpload bool   `json:"delete_after_upload,omitempty"`
}

APIQueueUploadRequest is the JSON body accepted by the gated upload endpoint.

type APIQueueUploadResult added in v0.0.30

type APIQueueUploadResult struct {
	Status string `json:"status"`
	File   string `json:"file"`
}

APIQueueUploadResult describes the side-effect of a successful enqueue call.

type App

type App struct {
	// contains filtered or unexported fields
}

App struct for the Wails application

func NewApp

func NewApp() *App

NewApp creates a new App application struct

func (*App) AddFilesToQueue

func (a *App) AddFilesToQueue() error

AddFilesToQueue adds multiple files to the queue for processing

func (*App) ApplyPendingConfig added in v0.0.13

func (a *App) ApplyPendingConfig() error

ApplyPendingConfig manually applies pending configuration changes

func (*App) CancelJob

func (a *App) CancelJob(id string) error

CancelJob cancels a running job via processor

func (*App) CancelUpload

func (a *App) CancelUpload() error

CancelUpload is no longer used - individual jobs are cancelled via CancelJob This function is kept for backward compatibility but does nothing

func (*App) ClearQueue

func (a *App) ClearQueue() error

ClearQueue removes all completed and failed items from the queue via queue

func (*App) DebugQueueItem

func (a *App) DebugQueueItem(id string) (map[string]any, error)

DebugQueueItem returns debug information about a queue item

func (*App) DiscardPendingConfig added in v0.0.13

func (a *App) DiscardPendingConfig() error

DiscardPendingConfig discards pending configuration changes

func (*App) DownloadLogFile added in v0.0.29

func (a *App) DownloadLogFile() error

DownloadLogFile opens a save dialog and downloads the log file

func (*App) DownloadNZB

func (a *App) DownloadNZB(id string) error

DownloadNZB downloads the NZB file for a completed item

func (*App) EnqueueAPIUpload added in v0.0.30

func (a *App) EnqueueAPIUpload(ctx context.Context, req APIQueueUploadRequest) (*APIQueueUploadResult, error)

EnqueueAPIUpload validates an API upload request and pushes it onto the queue with the appropriate per-job options. Used by the HTTP handler in cmd/web.

func (*App) GetAPIKey added in v0.0.30

func (a *App) GetAPIKey() (string, error)

GetAPIKey returns the persisted HTTP API key, generating one on first call when none exists. Exposed to the desktop UI via Wails.

func (*App) GetAppStatus

func (a *App) GetAppStatus() AppStatus

GetAppStatus returns the current application status

func (*App) GetAppliedConfig added in v0.0.13

func (a *App) GetAppliedConfig() (*config.ConfigData, error)

GetAppliedConfig returns the currently applied configuration (ignoring pending)

func (*App) GetArrInstances added in v0.0.30

func (a *App) GetArrInstances() ([]config.ArrInstance, error)

GetArrInstances returns all configured arr instances.

func (*App) GetAutoPauseReason added in v0.0.20

func (a *App) GetAutoPauseReason() string

GetAutoPauseReason returns the reason for automatic pause, if any

func (*App) GetConfig

func (a *App) GetConfig() (*config.ConfigData, error)

GetConfig returns the current configuration (pending config if available, otherwise applied config)

func (*App) GetConfigPath

func (a *App) GetConfigPath() string

GetConfigPath returns the path to the configuration file

func (*App) GetLoggingStatus added in v0.0.10

func (a *App) GetLoggingStatus() map[string]any

GetLoggingStatus returns information about logging configuration

func (*App) GetLogs

func (a *App) GetLogs() (string, error)

GetLogs returns the content of the log file.

func (*App) GetLogsPaginated

func (a *App) GetLogsPaginated(limit, offset int) (string, error)

GetLogsPaginated returns paginated log content limit: number of lines to return (0 = use original 1MB limit) offset: number of lines to skip from the end (0 = start from most recent)

func (*App) GetMigrationStatus added in v0.0.22

func (a *App) GetMigrationStatus() (map[string]any, error)

GetMigrationStatus returns the current migration status

func (*App) GetNZB added in v0.0.22

func (a *App) GetNZB(id string) (content string, fileName string, err error)

GetNZBContent returns the content of an NZB file for a completed item

func (*App) GetNntpPoolMetrics added in v0.0.16

func (a *App) GetNntpPoolMetrics() (NntpPoolMetrics, error)

GetNntpPoolMetrics returns NNTP connection pool metrics from the singleton pool manager

func (*App) GetOutputDirectory

func (a *App) GetOutputDirectory() string

GetOutputDirectory returns the current output directory

func (*App) GetPendingConfigStatus added in v0.0.13

func (a *App) GetPendingConfigStatus() map[string]any

GetPendingConfigStatus returns the status of pending config changes

func (*App) GetProcessorStatus

func (a *App) GetProcessorStatus() ProcessorStatus

GetProcessorStatus returns processor status information

func (*App) GetQueueItems

func (a *App) GetQueueItems(params PaginationParams) (*PaginatedQueueResult, error)

GetQueueItems returns the current queue items from the queue

func (*App) GetQueueStats

func (a *App) GetQueueStats() (QueueStats, error)

GetQueueStats returns statistics about the queue via queue

func (*App) GetRunningJobs

func (a *App) GetRunningJobs() ([]processor.RunningJobItem, error)

GetRunningJobs returns currently running jobs from the processor

func (*App) GetRunningJobsDetails added in v0.0.13

func (a *App) GetRunningJobsDetails() ([]processor.RunningJobDetails, error)

GetRunningJobsDetails returns detailed information about currently running jobs

func (*App) GetTransferRuntimeMetrics added in v0.0.30

func (a *App) GetTransferRuntimeMetrics() TransferRuntimeMetrics

GetTransferRuntimeMetrics returns process-wide upload/PAR2 scheduler metrics (active/queued upload workers, reserved/configured buffer bytes, active/queued PAR2 jobs) for the diagnostics dashboard. Zero value when no processor.

func (*App) GetWatchDirectory

func (a *App) GetWatchDirectory() string

GetWatchDirectory returns the current watch directory

func (*App) GetWatcherStatus added in v0.0.24

func (a *App) GetWatcherStatus() []watcher.WatcherStatusInfo

GetWatcherStatus returns the current status of all watchers

func (*App) HandleDroppedFiles

func (a *App) HandleDroppedFiles(filePaths []string) error

HandleDroppedFiles processes files that are dropped onto the application window

func (*App) HasPendingConfigChanges added in v0.0.13

func (a *App) HasPendingConfigChanges() bool

HasPendingConfigChanges returns whether there are pending config changes

func (*App) IsAPIEnabled added in v0.0.30

func (a *App) IsAPIEnabled() bool

IsAPIEnabled reports whether the gated HTTP API endpoint is currently enabled in config.

func (*App) IsLegacyDatabase added in v0.0.22

func (a *App) IsLegacyDatabase() (bool, error)

IsLegacyDatabase checks if the database is a legacy (non-goose) database

func (*App) IsProcessingAutoPaused added in v0.0.20

func (a *App) IsProcessingAutoPaused() bool

IsProcessingAutoPaused returns whether the processor was automatically paused due to provider unavailability

func (*App) IsProcessingPaused added in v0.0.14

func (a *App) IsProcessingPaused() bool

IsProcessingPaused returns whether the processor is currently paused

func (*App) IsUploading

func (a *App) IsUploading() bool

IsUploading returns whether any uploads are in progress (via processor)

func (*App) MigrateTo added in v0.0.22

func (a *App) MigrateTo(version int64) error

MigrateTo migrates to a specific version

func (*App) NavigateToDashboard

func (a *App) NavigateToDashboard()

NavigateToDashboard emits an event to navigate to the dashboard page

func (*App) NavigateToSettings

func (a *App) NavigateToSettings()

NavigateToSettings emits an event to navigate to the settings page

func (*App) PauseProcessing added in v0.0.14

func (a *App) PauseProcessing() error

PauseProcessing pauses the processor to prevent new jobs from starting

func (*App) RecreateDatabase added in v0.0.22

func (a *App) RecreateDatabase() error

RecreateDatabase drops all tables and recreates them using migrations

func (*App) RegenerateAPIKey added in v0.0.30

func (a *App) RegenerateAPIKey() (string, error)

RegenerateAPIKey replaces the stored key with a fresh one and returns the new value. Exposed to the desktop UI via Wails.

func (*App) RemoveArrInstance added in v0.0.30

func (a *App) RemoveArrInstance(ctx context.Context, instanceID string) error

RemoveArrInstance removes the arr webhook from the app and deletes the instance from config. If the webhook cannot be removed from arr (e.g. the arr instance is unreachable), the instance is still removed from config.

func (*App) RemoveFromQueue

func (a *App) RemoveFromQueue(id string) error

RemoveFromQueue removes an item from the queue via queue

func (*App) ResetDatabase added in v0.0.22

func (a *App) ResetDatabase() error

ResetDatabase drops all tables and re-runs all migrations

func (*App) ResumeProcessing added in v0.0.14

func (a *App) ResumeProcessing() error

ResumeProcessing resumes the processor to allow new jobs to start

func (*App) RetryJob

func (a *App) RetryJob(id string) error

RetryJob retries a failed job

func (*App) RetryScript added in v0.0.29

func (a *App) RetryScript(id string) error

RetryScript manually retries a failed post-upload script execution

func (*App) RollbackMigration added in v0.0.22

func (a *App) RollbackMigration() error

RollbackMigration rolls back the last applied migration

func (*App) RunMigrations added in v0.0.22

func (a *App) RunMigrations() error

RunMigrations runs all pending migrations

func (*App) SaveConfig

func (a *App) SaveConfig(configData *config.ConfigData) error

SaveConfig saves the configuration

func (*App) SelectConfigFile

func (a *App) SelectConfigFile() (string, error)

SelectConfigFile allows user to select a config file

func (*App) SelectFolder added in v0.0.29

func (a *App) SelectFolder() (string, error)

SelectFolder opens a native folder picker dialog and returns the selected folder path Returns empty string if no folder was selected

func (*App) SelectFolders added in v0.0.30

func (a *App) SelectFolders() ([]string, error)

SelectFolders opens a native multi-select dialog and returns paths of all selected folders. Returns nil slice (not an error) when the user cancels.

func (*App) SelectOutputDirectory

func (a *App) SelectOutputDirectory() (string, error)

SelectOutputDirectory allows user to select an output directory

func (*App) SelectTempDirectory

func (a *App) SelectTempDirectory() (string, error)

SelectTempDirectory allows user to select a temporary directory for PAR2 files

func (*App) SelectWatchDirectory

func (a *App) SelectWatchDirectory() (string, error)

SelectWatchDirectory allows user to select a watch directory

func (*App) SetQueueItemPriority

func (a *App) SetQueueItemPriority(id string, priority int) error

SetQueueItemPriority updates the priority of a pending queue item by id and reorders the queue

func (*App) SetWebEventEmitter

func (a *App) SetWebEventEmitter(emitter func(eventType string, data any))

SetWebEventEmitter sets the event emitter function for web mode

func (*App) SetWebMode

func (a *App) SetWebMode(isWeb bool)

SetWebMode sets the application to web mode

func (*App) SetupArrWebhook added in v0.0.30

func (a *App) SetupArrWebhook(ctx context.Context, instance config.ArrInstance, webhookURL string) (config.ArrInstance, error)

SetupArrWebhook registers a Postie import webhook with the given arr instance, persists the instance (with the returned WebhookID) to config, and saves config. webhookURL must be the full URL Postie is reachable at, including the ?apiKey query param so arr can authenticate the call.

func (*App) SetupWizardComplete added in v0.0.7

func (a *App) SetupWizardComplete(wizardData SetupWizardData) error

SetupWizardComplete saves the configuration from the setup wizard

func (*App) Shutdown added in v0.0.16

func (a *App) Shutdown()

Shutdown gracefully shuts down the application and closes all resources

func (*App) Startup

func (a *App) Startup(ctx context.Context)

Startup is called when the app starts. The context is saved so we can call the runtime methods

func (*App) TestArrConnection added in v0.0.30

func (a *App) TestArrConnection(ctx context.Context, instance config.ArrInstance) error

TestArrConnection verifies the given arr instance is reachable and the API key is valid.

func (*App) TestProviderConnectivity added in v0.0.20

func (a *App) TestProviderConnectivity(serverData ServerData) ValidationResult

TestProviderConnectivity tests an individual provider's connectivity using the nntppool v4 method

func (*App) TriggerScan added in v0.0.29

func (a *App) TriggerScan()

TriggerScan triggers an immediate directory scan on all active watchers

func (*App) UploadFiles

func (a *App) UploadFiles() error

UploadFiles uploads the selected files using the queue system

func (*App) UploadFolder added in v0.0.29

func (a *App) UploadFolder(folderPath string) error

UploadFolder uploads all files from a folder as a single NZB The folder structure will be preserved in the article subjects

func (*App) UploadFolders added in v0.0.30

func (a *App) UploadFolders(folderPaths []string) error

UploadFolders queues multiple folders for upload as separate NZBs.

func (*App) ValidateNNTPServer added in v0.0.7

func (a *App) ValidateNNTPServer(serverData ServerData) ValidationResult

ValidateNNTPServer validates an NNTP server configuration using TestProviderConnectivity

type AppPaths

type AppPaths struct {
	Config   string
	Database string
	Data     string
	Log      string
}

AppPaths holds the various paths needed by the application

func GetAppPaths

func GetAppPaths() (*AppPaths, error)

GetAppPaths returns the appropriate paths for the current operating system

type AppStatus added in v0.0.8

type AppStatus struct {
	HasConfig           bool   `json:"hasConfig"`
	ConfigPath          string `json:"configPath"`
	Uploading           bool   `json:"uploading"`
	CriticalConfigError bool   `json:"criticalConfigError"`
	Error               string `json:"error"`
	IsFirstStart        bool   `json:"isFirstStart"`
	HasServers          bool   `json:"hasServers"`
	ServerCount         int    `json:"serverCount"`
	ValidServerCount    int    `json:"validServerCount"`
	ConfigValid         bool   `json:"configValid"`
	NeedsConfiguration  bool   `json:"needsConfiguration"`
	Version             string `json:"version"`
}

AppStatus represents the current application status

type NntpPoolMetrics added in v0.0.16

type NntpPoolMetrics struct {
	Timestamp         string                `json:"timestamp"`
	ActiveConnections int                   `json:"activeConnections"`
	TotalErrors       int64                 `json:"totalErrors"`
	AvgSpeed          float64               `json:"avgSpeed"`
	BytesConsumed     int64                 `json:"bytesConsumed"`
	Elapsed           string                `json:"elapsed"`
	ProviderErrors    map[string]int64      `json:"providerErrors"`
	Providers         []NntpProviderMetrics `json:"providers"`
}

NntpPoolMetrics represents NNTP connection pool metrics

type NntpProviderMetrics added in v0.0.16

type NntpProviderMetrics struct {
	Name              string  `json:"name"`
	Host              string  `json:"host"`
	ActiveConnections int     `json:"activeConnections"`
	MaxConnections    int     `json:"maxConnections"`
	AvailableSlots    int     `json:"availableSlots"`
	TotalErrors       int64   `json:"totalErrors"`
	AvgSpeed          float64 `json:"avgSpeed"`
	SpeedEwma         float64 `json:"speedEwma"` // recent throughput estimate (bytes/sec), 0 = no sample
	BytesConsumed     int64   `json:"bytesConsumed"`
	Missing           int64   `json:"missing"`
	PingRTT           string  `json:"pingRTT"`
	TTFB              string  `json:"ttfb"` // recent time-to-first-byte, "" = no sample
	Inflight          int     `json:"inflight"`
	QuotaBytes        int64   `json:"quotaBytes"` // 0 = no quota configured
	QuotaUsed         int64   `json:"quotaUsed"`
	QuotaResetAt      string  `json:"quotaResetAt"` // RFC3339, "" = no period
	QuotaExceeded     bool    `json:"quotaExceeded"`
}

NntpProviderMetrics represents metrics for individual NNTP providers

type PaginatedQueueResult added in v0.0.26

type PaginatedQueueResult struct {
	Items        []QueueItem `json:"items"`
	TotalItems   int         `json:"totalItems"`
	TotalPages   int         `json:"totalPages"`
	CurrentPage  int         `json:"currentPage"`
	ItemsPerPage int         `json:"itemsPerPage"`
	HasNext      bool        `json:"hasNext"`
	HasPrev      bool        `json:"hasPrev"`
}

PaginatedQueueResult contains paginated queue items and metadata

type PaginationParams added in v0.0.26

type PaginationParams struct {
	Page   int    `json:"page"`   // 1-based page number
	Limit  int    `json:"limit"`  // Items per page
	SortBy string `json:"sortBy"` // Sort field: "created", "priority", "status", "filename", "size"
	Order  string `json:"order"`  // Sort order: "asc", "desc"
	Status string `json:"status"` // Status filter: "pending", "complete", "error", or "" for all
}

PaginationParams defines parameters for paginated queries

type ProcessingPauseState added in v0.0.30

type ProcessingPauseState struct {
	Paused     bool   `json:"paused"`
	AutoPaused bool   `json:"autoPaused"`
	Reason     string `json:"reason"`
}

ProcessingPauseState is the payload broadcast with pause-related events. A full snapshot lets the UI render the header without follow-up RPCs.

type ProcessorStatus added in v0.0.8

type ProcessorStatus struct {
	HasProcessor  bool     `json:"hasProcessor"`
	RunningJobs   int      `json:"runningJobs"`
	RunningJobIDs []string `json:"runningJobIDs"`
}

ProcessorStatus represents the current processor status

type QueueItem

type QueueItem struct {
	ID                 string     `json:"id"`
	Path               string     `json:"path"`
	FileName           string     `json:"fileName"`
	Size               int64      `json:"size"`
	Status             string     `json:"status"`
	RetryCount         int        `json:"retryCount"`
	Priority           int        `json:"priority"`
	ErrorMessage       *string    `json:"errorMessage"`
	CreatedAt          time.Time  `json:"createdAt"`
	UpdatedAt          time.Time  `json:"updatedAt"`
	CompletedAt        *time.Time `json:"completedAt"`
	NzbPath            *string    `json:"nzbPath"`
	VerificationStatus *string    `json:"verificationStatus"`
}

QueueItem represents a queue item for the frontend - matches queue.QueueItem

type QueueStats added in v0.0.8

type QueueStats struct {
	Total               int `json:"total"`
	Pending             int `json:"pending"`
	Running             int `json:"running"`
	Complete            int `json:"complete"`
	Error               int `json:"error"`
	PendingVerification int `json:"pendingVerification"`
	VerificationFailed  int `json:"verificationFailed"`
}

QueueStats represents queue statistics

type ServerData added in v0.0.7

type ServerData struct {
	Name           string `json:"name"`
	Host           string `json:"host"`
	Port           int    `json:"port"`
	Username       string `json:"username"`
	Password       string `json:"password"`
	SSL            bool   `json:"ssl"`
	MaxConnections int    `json:"maxConnections"`
	Role           string `json:"role"` // "upload" | "verify" | "" (defaults to upload)
}

ServerData represents the server configuration data from the frontend

type SetupWizardData added in v0.0.7

type SetupWizardData struct {
	Servers         []ServerData `json:"servers"`
	OutputDirectory string       `json:"outputDirectory"`
	WatchDirectory  string       `json:"watchDirectory"`
}

SetupWizardData represents the complete setup wizard data from the frontend

type TransferRuntimeMetrics added in v0.0.30

type TransferRuntimeMetrics struct {
	UploadActiveWorkers int64 `json:"uploadActiveWorkers"`
	UploadQueuedWorkers int64 `json:"uploadQueuedWorkers"`
	UploadWorkerCount   int64 `json:"uploadWorkerCount"`
	UploadReservedBytes int64 `json:"uploadReservedBytes"`
	UploadBudgetBytes   int64 `json:"uploadBudgetBytes"`
	Par2ActiveJobs      int64 `json:"par2ActiveJobs"`
	Par2QueuedJobs      int64 `json:"par2QueuedJobs"`
	Par2Capacity        int   `json:"par2Capacity"`
}

TransferRuntimeMetrics is the backend-facing view of process-wide upload/PAR2 scheduler metrics for the diagnostics dashboard.

type ValidationResult added in v0.0.7

type ValidationResult struct {
	Valid bool   `json:"valid"`
	Error string `json:"error"`
}

ValidationResult represents the result of server validation

Jump to

Keyboard shortcuts

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