downloader

package
v1.11.11 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInternalResolution = errors.Sentinel("downloader: destination resolves to internal network location")
	ErrInvalidIPAddress   = errors.Sentinel("downloader: invalid IP address")
	ErrDownloadFailed     = errors.Sentinel("downloader: download request failed")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

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

func (*Counter) Write

func (c *Counter) Write(p []byte) (int, error)

type Download

type Download struct {
	Identifier string
	// contains filtered or unexported fields
}

func ByID

func ByID(dlid string) *Download

ByID returns a single Download matching a given identifier. If no download is found the second argument in the response will be false.

func ByServer

func ByServer(sid string) []*Download

ByServer returns all the tracked downloads for a given server instance.

func New

New starts a new tracked download which allows for cancellation later on by calling the Downloader.Cancel function.

func (*Download) BelongsTo

func (dl *Download) BelongsTo(s *server.Server) bool

BelongsTo checks if the given download belongs to the provided server.

func (*Download) Cancel

func (dl *Download) Cancel()

Cancel cancels a running download and frees up the associated resources. If a file is being written a partial file will remain present on the disk.

func (*Download) Execute

func (dl *Download) Execute() error

Execute executes a given download for the server and begins writing the file to the disk. Once completed the download will be removed from the cache.

func (Download) MarshalJSON

func (dl Download) MarshalJSON() ([]byte, error)

func (*Download) Path

func (dl *Download) Path() string

func (*Download) Progress

func (dl *Download) Progress() float64

Progress returns the current progress of the download as a float value between 0 and 1 where 1 indicates that the download is completed.

type DownloadRequest

type DownloadRequest struct {
	Directory string
	URL       *url.URL
	FileName  string
	UseHeader bool
}

type Downloader

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

Downloader represents a global downloader that keeps track of all currently processing downloads for the machine.

Jump to

Keyboard shortcuts

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