Package download
- Constants
- Variables
- func AddGlobalProgressBar(d *Download)
- func AddLocalProgressBar(index int, pieceCount int, r *ByteRange)
- func DownloadPath(defaultFileName string) string
- func InitializeProgress(width int)
- func ShutdownProgress(success bool)
- type ByteRange
- func NewByteRange(start, end, wrote int64) *ByteRange
- func (r *ByteRange) String() string
- type BytesWrote
- type ControlFile
- func ParseControlFile(filePath string) (*ControlFile, error)
- func (cf *ControlFile) String() string
- type ControlWriter
- func NewControlWriter(w io.WriterAt, offset int64) *ControlWriter
- func (w *ControlWriter) Write(b []byte) (n int, err error)
- type Download
- func NewDownload(url string, postData []byte) (*Download, error)
- func (d *Download) Cancel()
- func (d *Download) Download(postData []byte) error
- func (d *Download) GetDownloaded() int64
- func (d *Download) GetStatus() int
- func (d *Download) GetVerboseDownloaded() []byte
- func (d *Download) Pause()
- func (d *Download) Resume()
- func (d *Download) Wait()
- type DownloadWriter
- func NewDownloadWriter(w io.WriterAt, r *ByteRange) *DownloadWriter
- func (w *DownloadWriter) Write(b []byte) (n int, err error)
- type GlobalBarInfo
- type Metadata
- func FetchMetadata(url string, postData []byte) (*Metadata, error)
- type RangeBarInfo
Package files
controlfile.go
download.go
fileio.go
progress.go
progress_other.go
Constants
const (
WriteBufferSize = 64 * 1024
DiskAllocationWarningSize = 24 * 1024 * 1024
ProgressCompletedSize = 10000
)
const (
RefreshRate = 120 * time.Millisecond
SpeedAverageWindow = 45.0
BarStyle = "|-> |"
)
Variables
var (
NewID chan int64
)
func AddGlobalProgressBar(d *Download)
func AddLocalProgressBar(index int, pieceCount int, r *ByteRange)
func DownloadPath(defaultFileName string) string
func InitializeProgress(width int)
func ShutdownProgress(success bool)
type ByteRange struct {
Start int64
End int64
Wrote int64
Progress int64
LastWrote time.Time
}
func NewByteRange(start, end, wrote int64) *ByteRange
func (*ByteRange) String
¶
func (r *ByteRange) String() string
type BytesWrote struct {
Wrote int
Duration time.Duration
}
type ControlFile struct {
URLs []string
Ranges []*ByteRange
}
func ParseControlFile(filePath string) (*ControlFile, error)
func (*ControlFile) String
¶
func (cf *ControlFile) String() string
type ControlWriter struct {
io.WriterAt
Cancelled chan bool
}
func NewControlWriter(w io.WriterAt, offset int64) *ControlWriter
func (*ControlWriter) Write
¶
func (w *ControlWriter) Write(b []byte) (n int, err error)
type Download struct {
ID int64
Status int
URL string
Name string
Size int64
Remaining int64
SupportsRange bool
Ranges []*ByteRange
Writers []*DownloadWriter
ControlWriters []*ControlWriter
FilePath string
Started time.Time
Finished time.Time
WasPaused bool
Retries int
InProgress bool
Paused bool
Cancelled bool
*sync.RWMutex
}
func NewDownload(url string, postData []byte) (*Download, error)
func (*Download) Cancel
¶
func (d *Download) Cancel()
func (d *Download) Download(postData []byte) error
func (d *Download) GetDownloaded() int64
func (d *Download) GetStatus() int
func (d *Download) GetVerboseDownloaded() []byte
func (*Download) Pause
¶
func (d *Download) Pause()
func (*Download) Resume
¶
func (d *Download) Resume()
func (*Download) Wait
¶
func (d *Download) Wait()
type DownloadWriter struct {
io.WriterAt
Range *ByteRange
Cancelled bool
}
func NewDownloadWriter(w io.WriterAt, r *ByteRange) *DownloadWriter
func (*DownloadWriter) Write
¶
func (w *DownloadWriter) Write(b []byte) (n int, err error)
type GlobalBarInfo struct {
Name string
Size int64
Pieces int
Progress chan *BytesWrote
}
type Metadata struct {
Name string
Size int64
SupportsRange bool
}
func FetchMetadata(url string, postData []byte) (*Metadata, error)
type RangeBarInfo struct {
Index int
Size int64
Progress chan *BytesWrote
}