download

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, url string, outPath string, progressCh chan<- any, id string) error

Download is the CLI entry point (non-TUI) - convenience wrapper

func TUIDownload

func TUIDownload(ctx context.Context, cfg *types.DownloadConfig) error

TUIDownload is the main entry point for downloads executed by the Engine pool

Types

type ProbeResult

type ProbeResult struct {
	FileSize      int64
	SupportsRange bool
	Filename      string
	ContentType   string
}

ProbeResult contains all metadata from server probe

type WorkerPool

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

func NewWorkerPool

func NewWorkerPool(progressCh chan<- any, maxDownloads int) *WorkerPool

func (*WorkerPool) ActiveCount

func (p *WorkerPool) ActiveCount() int

ActiveCount returns the number of currently active (downloading/pausing) downloads

func (*WorkerPool) Add

func (p *WorkerPool) Add(cfg types.DownloadConfig)

Add adds a new download task to the pool. The caller (LifecycleManager) is responsible for emitting any lifecycle events (e.g. DownloadQueuedMsg).

func (*WorkerPool) Cancel

func (p *WorkerPool) Cancel(downloadID string) types.CancelResult

Cancel cancels and removes a download by ID. Returns metadata about what was removed so the caller (LifecycleManager) can emit events and handle cleanup. No events are emitted by the pool itself.

func (*WorkerPool) ExtractPausedConfig added in v0.7.8

func (p *WorkerPool) ExtractPausedConfig(downloadID string) *types.DownloadConfig

ExtractPausedConfig atomically removes a paused download from the pool and returns its config (with state cleared for re-enqueue) so the LifecycleManager can resume it. Returns nil if the download is not found, not paused, or still transitioning (pausing).

func (*WorkerPool) GetAll

func (p *WorkerPool) GetAll() []types.DownloadConfig

GetAll returns all active download configs (for listing)

func (*WorkerPool) GetStatus

func (p *WorkerPool) GetStatus(id string) *types.DownloadStatus

GetStatus returns the status of an active download

func (*WorkerPool) GracefulShutdown

func (p *WorkerPool) GracefulShutdown()

GracefulShutdown pauses all downloads and waits for them to save state

func (*WorkerPool) HasDownload

func (p *WorkerPool) HasDownload(url string) bool

HasDownload reports whether a download with the given URL is currently active or queued in the pool.

func (*WorkerPool) Pause

func (p *WorkerPool) Pause(downloadID string) bool

Pause pauses a specific download by ID. Returns true if found and pause initiated (or already paused), false otherwise. Pure mechanical operation — no events emitted.

func (*WorkerPool) PauseAll

func (p *WorkerPool) PauseAll()

PauseAll pauses all active downloads (for graceful shutdown)

func (*WorkerPool) UpdateURL

func (p *WorkerPool) UpdateURL(downloadID string, newURL string) error

UpdateURL updates the in-memory URL of a download by ID. The caller (LifecycleManager) is responsible for persisting the change to the DB. It fails if the download is actively downloading (not paused or errored).

Jump to

Keyboard shortcuts

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