downloader

package
v0.0.0-...-2b5bdcb Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NewSpaceAllocator space allocator constructor.
	//nolint:gochecknoglobals // used for unit test mock
	NewSpaceAllocator = spaceallocator.New

	// ErrNotExist not exist download info error.
	ErrNotExist         = errors.New("download info not exist")
	ErrPartlyDownloaded = errors.New("file not fully downloaded")
)

Functions

This section is empty.

Types

type AlertSender

type AlertSender interface {
	SendAlert(alert cloudprotocol.AlertItem)
}

AlertSender provides alert sender interface.

type DownloadInfo

type DownloadInfo struct {
	Path            string
	TargetType      string
	InterruptReason string
	Downloaded      bool
}

PackageInfo struct contains download info data.

type Downloader

type Downloader struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Downloader instance.

func New

func New(moduleID string, cfg *config.Config, sender AlertSender, storage Storage) (
	downloader *Downloader, err error,
)

New creates new downloader object.

func (*Downloader) Close

func (downloader *Downloader) Close() (err error)

Close closes downloader.

func (*Downloader) Download

func (downloader *Downloader) Download(
	ctx context.Context, packageInfo PackageInfo,
) (result Result, err error)

Download downloads, decrypts and verifies package.

func (*Downloader) Release

func (downloader *Downloader) Release(filePath string) error

func (*Downloader) ReleaseByType

func (downloader *Downloader) ReleaseByType(targetType string) error

type PackageInfo

type PackageInfo struct {
	URLs                []string
	Sha256              []byte
	Sha512              []byte
	Size                uint64
	TargetType          string
	TargetID            string
	TargetAosVersion    uint64
	TargetVendorVersion string
}

PackageInfo struct contains package info data.

type Result

type Result interface {
	GetFileName() (fileName string)
	Wait() (err error)
}

Result download result interface.

type Storage

type Storage interface {
	GetDownloadInfo(filePath string) (DownloadInfo, error)
	GetDownloadInfos() ([]DownloadInfo, error)
	RemoveDownloadInfo(filePath string) error
	SetDownloadInfo(downloadInfo DownloadInfo) error
}

Storage provides API to add, remove, update or access download info data.

Jump to

Keyboard shortcuts

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