downloadmgr

package
v0.1.28 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidStatusCode = errors.New("status code was not 200")

ErrInvalidStatusCode is returned if the status code was not 200

Functions

This section is empty.

Types

type DownloadManager

type DownloadManager struct {
	OnProgress func(p int)
	// contains filtered or unexported fields
}

DownloadManager includes a queue to download

func New

func New() *DownloadManager

New creates a new downloadmgr

func (*DownloadManager) Add

func (d *DownloadManager) Add(i Downloader)

Add adds a new item to the queue

func (*DownloadManager) Start

func (d *DownloadManager) Start(ctx context.Context) error

Start starts the download queue

type Downloader

type Downloader interface {
	Download(ctx context.Context) error
}

Downloader allows downloadmgr to download the file

type ErrFailedAttempt

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

func (*ErrFailedAttempt) Error

func (e *ErrFailedAttempt) Error() string

type ErrInvalidSha

type ErrInvalidSha struct {
	FileName    string
	ExpectedSha string
	ActualSha   string
}

ErrInvalidSha is returned when the downloaded file's sha256 sum does not match the given sha1

func (*ErrInvalidSha) Error

func (e *ErrInvalidSha) Error() string

type HTTPItem

type HTTPItem struct {
	Client *http.Client
	URL    string
	Target string
	Size   int
	Sha256 string
	// contains filtered or unexported fields
}

HTTPItem is a URL, target pair with optional properties that will be downloaded using http(s)

func NewHTTPItem

func NewHTTPItem(URL string, Target string) *HTTPItem

NewHTTPItem creates a Item to be queued that will download the file using HTTP(S)

func (*HTTPItem) Download

func (i *HTTPItem) Download(ctx context.Context) error

Download downloads the item to the defined target using http

type Item

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

type WriteCounter added in v0.0.63

type WriteCounter struct {
	Total *int64 // Total # of bytes transferred
}

WriteCounter counts the number of bytes written to it.

func (*WriteCounter) Write added in v0.0.63

func (wc *WriteCounter) Write(p []byte) (int, error)

Write implements the io.Writer interface.

Always completes and never returns an error.

Jump to

Keyboard shortcuts

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