cmd

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Version string = "v0.1.0"

Variables

View Source
var (
	ChunkSizeMB      int = 1 // 1MB
	AutoDetectChunks bool
	OutputDir        string
	Workers          int
)
View Source
var (
	ErrRangeNotSupported = errors.New("Range not supported, disable chunking download")
)

Functions

func Execute

func Execute()

Types

type Chunk

type Chunk struct {
	Data  []byte
	Start int
	End   int
	Index int
}

func (*Chunk) Download

func (c *Chunk) Download(url string, chunkSize float64, size int64) error

func (*Chunk) WriteToFile

func (c *Chunk) WriteToFile(f *os.File) error

type ChunkHandler

type ChunkHandler interface {
	Download(url string) error
	WriteToFile(f *os.File)
}

type FileInfo

type FileInfo struct {
	File          *os.File
	Dir           string
	Name          string
	Ext           string
	Size          int64
	ChunkSize     float64
	AcceptsRanges bool
}

func (*FileInfo) CreateFile

func (f *FileInfo) CreateFile(outDir string) error

func (*FileInfo) DownloadChunk

func (fi *FileInfo) DownloadChunk(i int, url string)

func (*FileInfo) DownloadInChunks

func (fi *FileInfo) DownloadInChunks(url string) int

func (*FileInfo) GetFullPath

func (f *FileInfo) GetFullPath(outDir string) string

func (*FileInfo) StreamBufInChunks

func (fi *FileInfo) StreamBufInChunks(url string) (int64, error)

type FileInfoHandler

type FileInfoHandler interface {
	CreateFile(outDir string) error
	GetFullPath(outDir string) string
	DownloadInChunks(fi *FileInfo, url string)
}

Jump to

Keyboard shortcuts

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