jobs

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 41 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jobs provides the built-in scheduler job definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivityPrune

func ActivityPrune(svc *activity.Service, logger *slog.Logger) scheduler.Job

ActivityPrune returns a Job that deletes activity log entries older than 30 days.

func DownloadCleanup

func DownloadCleanup(q db.Querier, dlSvc *downloader.Service, blocklistSvc *blocklist.Service, logger *slog.Logger) scheduler.Job

DownloadCleanup returns a Job that removes finished torrents from the download client once their import outcome is known:

  • imported + seed target met → remove with data, keep the grab 'completed' (only the client artifact is gone)
  • failed import + blocklisted → the payload is known garbage (fake .exe/.scr uploads); remove with data immediately and mark the grab removed

Without this, /downloads grew forever: nothing ever told Haul a download had served its purpose.

func FileExistenceReconciler

func FileExistenceReconciler(q db.Querier, bus *events.Bus, logger *slog.Logger) scheduler.Job

FileExistenceReconciler returns a Job that walks every episode_files row and stats the underlying path. When the file is gone (operator rm'd it via the shell, mount disappeared, etc.), the row is deleted and episodes.has_file is flipped back to FALSE. A second pass picks up any `completed` grab whose episode currently lacks has_file and fires TypeImportRetryNeeded so the activity log surfaces the divergence and (future) auto-retry can act on it.

This is the on-ramp toward the haul-as-source-of-truth migration from the lifecycle-trust plan: we don't yet trust haul to drive state, but we do periodically reconcile what pilot believes against what the filesystem actually reports.

The reconciler is intentionally read-then-write per row. Tearing through it as a single SQL DELETE … WHERE NOT EXISTS would be faster but couldn't fire per-episode events, and would make a stale-mount scenario (every stat returns ENOENT for 30 seconds) catastrophic instead of recoverable. The current shape limits the blast radius to whatever paths actually return ENOENT during this pass — and the next pass cleans up anything that flipped between runs.

func HealthCheck

func HealthCheck(svc *health.Service) scheduler.Job

HealthCheck returns a Job that tests every enabled download client and indexer so the health list stays current.

func ImportListSync

func ImportListSync(svc *importlist.Service, logger *slog.Logger) scheduler.Job

ImportListSync returns a Job that syncs all enabled import lists every 6 hours.

func ImportRetry

func ImportRetry(svc *importer.Service, logger *slog.Logger) scheduler.Job

ImportRetry returns a Job that re-runs imports that failed after the download completed (unwritable library folder, transient I/O error, etc.), so they recover without anyone re-importing by hand.

func LibraryScan

func LibraryScan(libSvc *library.Service, showSvc *show.Service, um *unmapped.Service, q db.Querier, logger *slog.Logger) scheduler.Job

LibraryScan returns a Job that walks all library root directories, records folders no series claims for review (they are not added automatically; see internal/core/unmapped), then matches video files to known series/episodes and creates episode_file records.

func QueuePoll

func QueuePoll(svc *queue.Service, interval time.Duration, logger *slog.Logger) scheduler.Job

QueuePoll returns a Job that polls all active downloads and updates their status in the database. Runs at the given interval (minimum 10 seconds).

func RSSSync

func RSSSync(
	idxSvc *indexer.Service,
	showQ db.Querier,
	dlSvc *downloader.Service,
	blocklistSvc *blocklist.Service,
	profiles ProfileGetter,
	logger *slog.Logger,
) scheduler.Job

RSSSync returns a Job that polls all enabled indexers for recent releases, matches them against monitored series/episodes, and automatically grabs the best release each wanted episode's quality profile accepts: missing episodes, upgrades below the cutoff, and PROPER/REPACK fixes. Runs every 15 minutes.

func RecycleBinCleanup

func RecycleBinCleanup(svc *recyclebin.Service, logger *slog.Logger) scheduler.Job

RecycleBinCleanup returns a Job that deletes files older than the cleanup period from the recycle bin.

func RefreshMetadata

func RefreshMetadata(showSvc *show.Service, logger *slog.Logger) scheduler.Job

RefreshMetadata returns a Job that re-fetches metadata for all series. Runs every 12 hours. Updates episode still images and runtimes from TMDB.

func ScheduledBackup

func ScheduledBackup(svc *backup.Service, logger *slog.Logger) scheduler.Job

ScheduledBackup returns a Job that makes a scheduled database backup when one is due and prunes old ones. It checks hourly; the backup interval itself is a setting (default weekly).

func StatsSnapshot

func StatsSnapshot(statsSvc *stats.Service, logger *slog.Logger) scheduler.Job

StatsSnapshot returns a Job that records a point-in-time stats snapshot daily.

Types

type ProfileGetter

type ProfileGetter interface {
	Get(ctx context.Context, id string) (quality.Profile, error)
}

ProfileGetter loads a quality profile by ID. quality.Service satisfies it.

Jump to

Keyboard shortcuts

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