Documentation
¶
Overview ¶
Package failedgrab handles downloads that a download client reports as failed: bad NZBs, missing usenet articles, torrent errors.
For every failed grab it blocklists the release so the same release is never grabbed again, and marks the grab failed. If the grab came from automatic search, it asks for a re-search by publishing TypeAutoSearchRetry, capped by the same per-episode circuit breaker the stall watcher uses. Grabs the user picked interactively are never re-searched automatically: the user decides what to do next.
This mirrors stallwatcher.handleStall for clients other than Haul's stall endpoint. Stalls and failures share one retry budget per episode (see CountRecentStallsForEpisode in blocklist.sql).
Index ¶
Constants ¶
const MaxRetriesPerEpisode = 3
MaxRetriesPerEpisode is the circuit breaker: once this many stall or download-failure blocklist entries exist for a (series, episode) in the last 24 hours, automatic re-search stops. Matches stallwatcher.MaxStallRetriesPerEpisode.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blocklister ¶
type Blocklister interface {
AddFromDownloadFailure(ctx context.Context, p blocklist.StallEntry) error
CountRecentStalls(ctx context.Context, seriesID, episodeID string) (int64, error)
}
Blocklister is the slice of blocklist.Service this package needs.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler reacts to failed downloads.
func New ¶
func New(bl Blocklister, bus Publisher, logger *slog.Logger) *Handler
New creates a Handler.
func (*Handler) HandleDownloadFailed ¶
func (h *Handler) HandleDownloadFailed(ctx context.Context, g db.GrabHistory, clientError string) error
HandleDownloadFailed blocklists the grab's release, announces the failure, and requests a re-search for automatic grabs that are still under the circuit breaker. clientError is the download client's own message, if it gave one. The caller is responsible for having already recorded the grab's status as failed.