stream

package
v1.54.10 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Files

func Files(
	ctx context.Context,
	t *torrent.Torrent,
	opts FilesOptions,
	h func(context.Context, *FileLease) error,
) error

Files downloads selected files, waits for each to complete, hands it to h, and releases storage if h does not explicitly Release or Discard the lease.

Types

type FileLease

type FileLease struct {
	File        *torrent.File
	Index       int
	Path        string
	DisplayPath string
	Length      int64
	Reader      io.ReadCloser
	// contains filtered or unexported fields
}

FileLease is a completed torrent file handed to a consumer.

func (*FileLease) Discard

func (l *FileLease) Discard(ctx context.Context) error

Discard finalizes a completed file without preserving completion.

func (*FileLease) Discarded added in v1.54.5

func (l *FileLease) Discarded() bool

Discarded reports whether Discard has completed successfully.

func (*FileLease) Finalized added in v1.54.5

func (l *FileLease) Finalized() bool

Finalized reports whether Release or Discard has completed successfully.

func (*FileLease) Release

func (l *FileLease) Release(ctx context.Context) error

Release finalizes a completed file that has been handed off to the caller.

func (*FileLease) Released added in v1.54.5

func (l *FileLease) Released() bool

Released reports whether Release has completed successfully.

type FileSelectionController added in v1.54.5

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

FileSelectionController lets callers change the file set used by Files while it is running. A nil selection means all files; an empty non-nil selection means no files.

func NewFileSelectionController added in v1.54.5

func NewFileSelectionController(indexes []int) *FileSelectionController

func (*FileSelectionController) Close added in v1.54.5

func (c *FileSelectionController) Close()

func (*FileSelectionController) SelectedFileIndexes added in v1.54.5

func (c *FileSelectionController) SelectedFileIndexes() []int

func (*FileSelectionController) SetSelectedFileIndexes added in v1.54.5

func (c *FileSelectionController) SetSelectedFileIndexes(indexes []int) error

type FilesOptions

type FilesOptions struct {
	// FileIndexes selects zero-based torrent file indexes. Nil means all
	// files; an empty non-nil slice means none.
	FileIndexes []int
	// Selection allows FileIndexes to be changed while Files is running. When
	// set, FileIndexes is ignored and Files runs until the context is cancelled,
	// the controller is closed, or an error occurs.
	Selection *FileSelectionController
	// MaxActive limits how many selected files are requested at once. Values
	// <=0 request all selected files at once.
	MaxActive int
	// Readahead overrides the Reader default when non-zero.
	Readahead int64
	// RequireExplicitRelease makes Files wait for the handler to call Release
	// or Discard when the handler returns nil without finalizing the lease.
	// While waiting, the lease still counts against MaxActive.
	RequireExplicitRelease bool
}

Jump to

Keyboard shortcuts

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