Documentation
¶
Index ¶
- Constants
- Variables
- type ClientError
- type Download
- func (u *Download) ChunckStream(chunck int64) (io.WriteSeeker, error)
- func (u *Download) DelTempDir() error
- func (u *Download) EncodedMetadata() string
- func (u *Download) ErrClean() error
- func (u *Download) Finished() bool
- func (u *Download) MergeStream(maxChunck int64) error
- func (u *Download) Offset() int64
- func (u *Download) Progress() int64
- func (u *Download) Size() int64
- type DownloadClient
- func (c *DownloadClient) Close() error
- func (c *DownloadClient) CreateDownload(download *Download) (*Downloader, error)
- func (c *DownloadClient) CreateOrResumeDownload(d *Download) (*Downloader, error)
- func (c *DownloadClient) DelFile(baseurl, filename string) error
- func (c *DownloadClient) FileList() ([]string, error)
- func (c *DownloadClient) GetMd5(baseUrl, filename string) (string, error)
- func (c *DownloadClient) ResumeDownload(d *Download) (*Downloader, error)
- type DownloadConfig
- type Downloader
Constants ¶
View Source
const ( GoNum = 10 MaxErr = 10 )
Variables ¶
View Source
var ( ErrNilUpload = errors.New("upload can't be nil") ErrLargeUpload = errors.New("upload body is to large") ErrUploadNotFound = errors.New("upload not found") ErrResumeNotEnabled = errors.New("resuming not enabled") ErrFingerprintNotSet = errors.New("fingerprint not set") ErrNilDownload = errors.New("download can't be nil") ErrDownloadNotFound = errors.New("download not found") )
Functions ¶
This section is empty.
Types ¶
type ClientError ¶
func (ClientError) Error ¶
func (c ClientError) Error() string
type Download ¶
type Download struct {
Fingerprint string // download任务的标识
Metadata downloadMeta
// contains filtered or unexported fields
}
func NewDownload ¶
先判断当前环境是否已经有这个下载任务了
func (*Download) ChunckStream ¶
func (u *Download) ChunckStream(chunck int64) (io.WriteSeeker, error)
func (*Download) DelTempDir ¶
func (*Download) EncodedMetadata ¶
func (*Download) MergeStream ¶
type DownloadClient ¶
type DownloadClient struct {
Config *DownloadConfig
// contains filtered or unexported fields
}
func NewDownloadClient ¶
func NewDownloadClient(url string, config *DownloadConfig) (*DownloadClient, error)
func (*DownloadClient) Close ¶ added in v0.0.8
func (c *DownloadClient) Close() error
func (*DownloadClient) CreateDownload ¶
func (c *DownloadClient) CreateDownload(download *Download) (*Downloader, error)
开始新的下载
func (*DownloadClient) CreateOrResumeDownload ¶
func (c *DownloadClient) CreateOrResumeDownload(d *Download) (*Downloader, error)
开始新的或者恢复下载
func (*DownloadClient) DelFile ¶
func (c *DownloadClient) DelFile(baseurl, filename string) error
发送调用,删除某个文件
func (*DownloadClient) FileList ¶
func (c *DownloadClient) FileList() ([]string, error)
func (*DownloadClient) GetMd5 ¶
func (c *DownloadClient) GetMd5(baseUrl, filename string) (string, error)
func (*DownloadClient) ResumeDownload ¶
func (c *DownloadClient) ResumeDownload(d *Download) (*Downloader, error)
恢复下载
type DownloadConfig ¶
type DownloadConfig struct {
Store store.DownloadStore
Resume bool
TempDir string
}
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
func (*Downloader) Abort ¶
func (d *Downloader) Abort()
func (*Downloader) CheckMd5 ¶
func (d *Downloader) CheckMd5(fingerprint string) error
func (*Downloader) Download ¶
func (d *Downloader) Download(isDel bool) error
下载文件,isDel下载完成后是否删除远端的文件
func (*Downloader) IsAborted ¶
func (d *Downloader) IsAborted() bool
func (*Downloader) MergeAndCheck ¶
func (d *Downloader) MergeAndCheck(maxTruncate int64, isDel bool) error
注意: 如果isDel是true,那么说明远端文件会删除,也就是这里只能校验一次 合并strem,校验md5,如果校验失败进行删除, isDel 如果校验成功是否删除远程文件
func (*Downloader) Offset ¶
func (d *Downloader) Offset() int64
Click to show internal directories.
Click to hide internal directories.