Documentation
¶
Overview ¶
Package jobs provides the built-in scheduler job definitions.
Index ¶
- func ActivityPrune(svc *activity.Service, logger *slog.Logger) scheduler.Job
- func DownloadCleanup(q db.Querier, dlSvc *downloader.Service, blocklistSvc *blocklist.Service, ...) scheduler.Job
- func FileExistenceReconciler(q db.Querier, bus *events.Bus, logger *slog.Logger) scheduler.Job
- func HealthCheck(svc *health.Service) scheduler.Job
- func ImportListSync(svc *importlist.Service, logger *slog.Logger) scheduler.Job
- func ImportRetry(svc *importer.Service, logger *slog.Logger) scheduler.Job
- func LibraryScan(libSvc *library.Service, showSvc *show.Service, um *unmapped.Service, ...) scheduler.Job
- func QueuePoll(svc *queue.Service, interval time.Duration, logger *slog.Logger) scheduler.Job
- func RSSSync(idxSvc *indexer.Service, showQ db.Querier, dlSvc *downloader.Service, ...) scheduler.Job
- func RecycleBinCleanup(svc *recyclebin.Service, logger *slog.Logger) scheduler.Job
- func RefreshMetadata(showSvc *show.Service, logger *slog.Logger) scheduler.Job
- func ScheduledBackup(svc *backup.Service, logger *slog.Logger) scheduler.Job
- func StatsSnapshot(statsSvc *stats.Service, logger *slog.Logger) scheduler.Job
- type ProfileGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActivityPrune ¶
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 ¶
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 ¶
HealthCheck returns a Job that tests every enabled download client and indexer so the health list stays current.
func ImportListSync ¶
ImportListSync returns a Job that syncs all enabled import lists every 6 hours.
func ImportRetry ¶
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 ¶
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 ¶
RecycleBinCleanup returns a Job that deletes files older than the cleanup period from the recycle bin.
func RefreshMetadata ¶
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 ¶
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).