Documentation
¶
Index ¶
- Variables
- type BackupProgress
- type CategoryApplied
- type CategoryPlan
- type CategorySpec
- type CategoryUpdate
- type Config
- type DiffChange
- type LiveCategory
- type LiveState
- type LiveTorrent
- type Manifest
- type ManifestItem
- type RestoreApplied
- type RestoreError
- type RestoreMode
- type RestoreOptions
- type RestorePlan
- type RestorePlanOptions
- type RestoreResult
- type Service
- func (s *Service) DataDir() string
- func (s *Service) DeleteAllRuns(ctx context.Context, instanceID int) error
- func (s *Service) DeleteRun(ctx context.Context, runID int64) error
- func (s *Service) ExecuteRestore(ctx context.Context, runID int64, mode RestoreMode, opts RestoreOptions) (*RestoreResult, error)
- func (s *Service) GetItem(ctx context.Context, runID int64, hash string) (*models.BackupItem, error)
- func (s *Service) GetProgress(runID int64) *BackupProgress
- func (s *Service) GetRun(ctx context.Context, runID int64) (*models.BackupRun, error)
- func (s *Service) GetSettings(ctx context.Context, instanceID int) (*models.BackupSettings, error)
- func (s *Service) ImportManifestFromDir(ctx context.Context, instanceID int, manifestData []byte, requestedBy string, ...) (*models.BackupRun, error)
- func (s *Service) ListRuns(ctx context.Context, instanceID int, limit, offset int) ([]*models.BackupRun, error)
- func (s *Service) LoadManifest(ctx context.Context, runID int64) (*Manifest, error)
- func (s *Service) PlanRestoreDiff(ctx context.Context, runID int64, mode RestoreMode, opts *RestorePlanOptions) (*RestorePlan, error)
- func (s *Service) PreviewRestore(ctx context.Context, runID int64, mode RestoreMode, opts *RestorePlanOptions) (*RestorePlan, error)
- func (s *Service) QueueRun(ctx context.Context, instanceID int, kind models.BackupRunKind, ...) (*models.BackupRun, error)
- func (s *Service) Start(ctx context.Context)
- func (s *Service) Stop()
- func (s *Service) UpdateSettings(ctx context.Context, settings *models.BackupSettings) error
- type SnapshotState
- type SnapshotTorrent
- type TagApplied
- type TagPlan
- type TagSpec
- type TagUpdate
- type TorrentApplied
- type TorrentPlan
- type TorrentSpec
- type TorrentUpdate
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInstanceBusy is returned when a backup is already running for the instance. ErrInstanceBusy = errors.New("backup already running for this instance") )
Functions ¶
This section is empty.
Types ¶
type BackupProgress ¶
type CategoryApplied ¶
type CategoryApplied struct {
Created []string `json:"created,omitempty"`
Updated []string `json:"updated,omitempty"`
Deleted []string `json:"deleted,omitempty"`
}
CategoryApplied summarises category operations.
type CategoryPlan ¶
type CategoryPlan struct {
Create []CategorySpec `json:"create,omitempty"`
Update []CategoryUpdate `json:"update,omitempty"`
Delete []string `json:"delete,omitempty"`
}
CategoryPlan bundles create/update/delete intents for categories.
type CategorySpec ¶
CategorySpec captures the desired state for a category during restore.
type CategoryUpdate ¶
type CategoryUpdate struct {
Name string `json:"name"`
CurrentPath string `json:"currentPath"`
DesiredPath string `json:"desiredPath"`
}
CategoryUpdate captures the changes required to align an existing category with the snapshot.
type DiffChange ¶
type DiffChange struct {
Field string `json:"field"`
Supported bool `json:"supported"`
Current any `json:"current,omitempty"`
Desired any `json:"desired,omitempty"`
Message string `json:"message,omitempty"`
}
DiffChange captures a single field difference between snapshot and live state.
type LiveCategory ¶
LiveCategory captures the current state for a category in qBittorrent.
type LiveState ¶
type LiveState struct {
InstanceID int `json:"instanceId"`
Categories map[string]LiveCategory `json:"categories"`
Tags map[string]struct{} `json:"tags"`
Torrents map[string]LiveTorrent `json:"torrents"`
}
LiveState represents the state of the live qBittorrent instance relevant for planning a restore.
type LiveTorrent ¶
type LiveTorrent struct {
Hash string `json:"hash"`
Name string `json:"name"`
Category string `json:"category"`
Tags []string `json:"tags"`
TrackerURLs []string `json:"trackerUrls,omitempty"`
InfoHashV1 string `json:"infoHashV1,omitempty"`
InfoHashV2 string `json:"infoHashV2,omitempty"`
SizeBytes int64 `json:"sizeBytes,omitempty"`
}
LiveTorrent captures the subset of torrent fields we need for planning.
type Manifest ¶
type Manifest struct {
InstanceID int `json:"instanceId"`
Kind string `json:"kind"`
GeneratedAt time.Time `json:"generatedAt"`
TorrentCount int `json:"torrentCount"`
Categories map[string]models.CategorySnapshot `json:"categories,omitempty"`
Tags []string `json:"tags,omitempty"`
Items []ManifestItem `json:"items"`
}
Manifest captures details about a backup run and its contents for API responses and archived metadata.
type ManifestItem ¶
type ManifestItem struct {
Hash string `json:"hash"`
Name string `json:"name"`
Category *string `json:"category,omitempty"`
SizeBytes int64 `json:"sizeBytes"`
ArchivePath string `json:"archivePath"`
InfoHashV1 *string `json:"infohashV1,omitempty"`
InfoHashV2 *string `json:"infohashV2,omitempty"`
Tags []string `json:"tags,omitempty"`
TorrentBlob string `json:"torrentBlob,omitempty"`
}
ManifestItem describes a single torrent contained in a backup archive.
type RestoreApplied ¶
type RestoreApplied struct {
Categories CategoryApplied `json:"categories"`
Tags TagApplied `json:"tags"`
Torrents TorrentApplied `json:"torrents"`
}
RestoreApplied summarises the actions that were successfully applied.
type RestoreError ¶
type RestoreError struct {
Operation string `json:"operation"`
Target string `json:"target"`
Message string `json:"message"`
}
RestoreError captures an operation failure during restore execution.
type RestoreMode ¶
type RestoreMode string
RestoreMode controls how a snapshot should be applied to a live qBittorrent instance.
const ( RestoreModeIncremental RestoreMode = "incremental" RestoreModeOverwrite RestoreMode = "overwrite" RestoreModeComplete RestoreMode = "complete" )
func ParseRestoreMode ¶
func ParseRestoreMode(value string) (RestoreMode, error)
ParseRestoreMode normalizes the provided mode string and ensures it is supported.
type RestoreOptions ¶
type RestoreOptions struct {
DryRun bool
StartPaused bool
SkipHashCheck bool
AutoResumeVerified bool
ExcludeHashes []string
}
RestoreOptions control restore execution behaviour.
type RestorePlan ¶
type RestorePlan struct {
Mode RestoreMode `json:"mode"`
RunID int64 `json:"runId"`
InstanceID int `json:"instanceId"`
Categories CategoryPlan `json:"categories"`
Tags TagPlan `json:"tags"`
Torrents TorrentPlan `json:"torrents"`
}
RestorePlan is the full set of actions required to align the live instance with the snapshot.
type RestorePlanOptions ¶
type RestorePlanOptions struct {
ExcludeHashes []string
}
RestorePlanOptions controls post-processing applied to a generated plan.
type RestoreResult ¶
type RestoreResult struct {
Mode RestoreMode `json:"mode"`
RunID int64 `json:"runId"`
InstanceID int `json:"instanceId"`
DryRun bool `json:"dryRun"`
Plan *RestorePlan `json:"plan"`
Applied RestoreApplied `json:"applied"`
Warnings []string `json:"warnings,omitempty"`
Errors []RestoreError `json:"errors,omitempty"`
}
RestoreResult describes the outcome of a restore execution.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(store *models.BackupStore, syncManager *qbittorrent.SyncManager, jackettSvc interface{}, cfg Config) *Service
func (*Service) DeleteAllRuns ¶
func (*Service) ExecuteRestore ¶
func (s *Service) ExecuteRestore(ctx context.Context, runID int64, mode RestoreMode, opts RestoreOptions) (*RestoreResult, error)
ExecuteRestore executes the restore plan for the given run and mode.
func (*Service) GetProgress ¶
func (s *Service) GetProgress(runID int64) *BackupProgress
func (*Service) GetSettings ¶
func (*Service) ImportManifestFromDir ¶ added in v1.8.0
func (s *Service) ImportManifestFromDir(ctx context.Context, instanceID int, manifestData []byte, requestedBy string, torrentPaths map[string]string) (*models.BackupRun, error)
ImportManifestFromDir imports a backup manifest with torrent files from temp paths. torrentPaths is a map of archivePath -> absolute temp file path on disk. The caller is responsible for cleaning up the temp files after this returns.
func (*Service) LoadManifest ¶
func (*Service) PlanRestoreDiff ¶
func (s *Service) PlanRestoreDiff(ctx context.Context, runID int64, mode RestoreMode, opts *RestorePlanOptions) (*RestorePlan, error)
PlanRestoreDiff loads snapshot and live state, returning the diff plan for the requested mode.
func (*Service) PreviewRestore ¶
func (s *Service) PreviewRestore(ctx context.Context, runID int64, mode RestoreMode, opts *RestorePlanOptions) (*RestorePlan, error)
PreviewRestore returns the diff plan without executing any mutations.
func (*Service) UpdateSettings ¶
type SnapshotState ¶
type SnapshotState struct {
RunID int64 `json:"runId"`
InstanceID int `json:"instanceId"`
Categories map[string]models.CategorySnapshot `json:"categories"`
Tags map[string]struct{} `json:"tags"`
Torrents map[string]SnapshotTorrent `json:"torrents"`
}
SnapshotState represents the desired state recorded in a backup snapshot.
type SnapshotTorrent ¶
type SnapshotTorrent struct {
Hash string `json:"hash"`
Name string `json:"name"`
Category *string `json:"category,omitempty"`
Tags []string `json:"tags,omitempty"`
ArchivePath string `json:"archivePath,omitempty"`
BlobPath string `json:"blobPath,omitempty"`
SizeBytes int64 `json:"sizeBytes,omitempty"`
InfoHashV1 *string `json:"infoHashV1,omitempty"`
InfoHashV2 *string `json:"infoHashV2,omitempty"`
}
SnapshotTorrent provides convenient access to torrent metadata captured in the snapshot.
type TagApplied ¶
type TagApplied struct {
Created []string `json:"created,omitempty"`
Deleted []string `json:"deleted,omitempty"`
}
TagApplied summarises tag operations.
type TagPlan ¶
type TagPlan struct {
Create []TagSpec `json:"create,omitempty"`
Delete []string `json:"delete,omitempty"`
}
TagPlan bundles create/delete intents for tags.
type TagSpec ¶
type TagSpec struct {
Name string `json:"name"`
}
TagSpec encapsulates a tag that should be present after restore.
type TorrentApplied ¶
type TorrentApplied struct {
Added []string `json:"added,omitempty"`
Updated []string `json:"updated,omitempty"`
Deleted []string `json:"deleted,omitempty"`
}
TorrentApplied summarises torrent operations.
type TorrentPlan ¶
type TorrentPlan struct {
Add []TorrentSpec `json:"add,omitempty"`
Update []TorrentUpdate `json:"update,omitempty"`
Delete []string `json:"delete,omitempty"`
}
TorrentPlan bundles add/update/delete intents for torrents.
type TorrentSpec ¶
type TorrentSpec struct {
Manifest ManifestItem `json:"manifest"`
}
TorrentSpec describes a torrent that should exist after the restore completes.
type TorrentUpdate ¶
type TorrentUpdate struct {
Hash string `json:"hash"`
Current LiveTorrent `json:"current"`
Desired SnapshotTorrent `json:"desired"`
Changes []DiffChange `json:"changes"`
}
TorrentUpdate captures adjustments required for an existing torrent.