Documentation ¶
Index ¶
- Constants
- Variables
- func BaiduPCSURLCheckFunc(client *requester.HTTPClient, durl string) (contentLength int64, resp *http.Response, err error)
- func CheckFileValid(filePath string, fileInfo *baidupcs.FileDirectory) error
- func FileExist(path string) bool
- func FixHTTPLinkURL(linkURL *url.URL)
- func GetLocateDownloadLinks(pcs *baidupcs.BaiduPCS, pcspath string) (dlinks []*url.URL, err error)
- func IsSkipMd5Checksum(size int64, md5Str string) bool
- type DownloadMode
- type DownloadStatistic
- type DownloadTaskUnit
- func (dtu *DownloadTaskUnit) OnComplete(lastRunResult *taskframework.TaskUnitRunResult)
- func (dtu *DownloadTaskUnit) OnFailed(lastRunResult *taskframework.TaskUnitRunResult)
- func (dtu *DownloadTaskUnit) OnRetry(lastRunResult *taskframework.TaskUnitRunResult)
- func (dtu *DownloadTaskUnit) OnSuccess(lastRunResult *taskframework.TaskUnitRunResult)
- func (dtu *DownloadTaskUnit) RetryWait() time.Duration
- func (dtu *DownloadTaskUnit) Run() (result *taskframework.TaskUnitRunResult)
- func (dtu *DownloadTaskUnit) SetTaskInfo(info *taskframework.TaskInfo)
Constants ¶
View Source
const ( // DefaultPrintFormat 默认的下载进度输出格式 DefaultPrintFormat = "\r[%s] ↓ %s/%s %s/s in %s, left %s ............" //DownloadSuffix 文件下载后缀 DownloadSuffix = ".BaiduPCS-Go-downloading" //StrDownloadInitError 初始化下载发生错误 StrDownloadInitError = "初始化下载发生错误" // StrDownloadFailed 下载文件失败 StrDownloadFailed = "下载文件失败" // StrDownloadGetDlinkFailed 获取下载链接失败 StrDownloadGetDlinkFailed = "获取下载链接失败" // StrDownloadChecksumFailed 检测文件有效性失败 StrDownloadChecksumFailed = "检测文件有效性失败" // StrDownloadCheckLengthFailed 检测文件大小一致性失败 StrDownloadCheckLengthFailed = "检测文件大小一致性失败" // DefaultDownloadMaxRetry 默认下载失败最大重试次数 DefaultDownloadMaxRetry = 3 )
Variables ¶
View Source
var ( // ErrDownloadNotSupportChecksum 文件不支持校验 ErrDownloadNotSupportChecksum = errors.New("该文件不支持校验") // ErrDownloadChecksumFailed 文件校验失败 ErrDownloadChecksumFailed = errors.New("该文件校验失败, 文件md5值与服务器记录的不匹配") // ErrDownloadFileBanned 违规文件 ErrDownloadFileBanned = errors.New("该文件可能是违规文件, 不支持校验") // ErrDlinkNotFound 未取得下载链接 ErrDlinkNotFound = errors.New("未取得下载链接") ErrShareInfoNotFound = errors.New("未在已分享列表中找到分享信息") )
Functions ¶
func BaiduPCSURLCheckFunc ¶
func BaiduPCSURLCheckFunc(client *requester.HTTPClient, durl string) (contentLength int64, resp *http.Response, err error)
BaiduPCSURLCheckFunc downloader 首次检查下载地址要执行的函数
func CheckFileValid ¶
func CheckFileValid(filePath string, fileInfo *baidupcs.FileDirectory) error
CheckFileValid 检测文件有效性
func FixHTTPLinkURL ¶
FixHTTPLinkURL 通过配置, 确定链接使用的协议(http,https)
func GetLocateDownloadLinks ¶
func IsSkipMd5Checksum ¶
IsSkipMd5Checksum 是否忽略某些校验
Types ¶
type DownloadMode ¶
type DownloadMode int
DownloadMode 下载模式
const ( DownloadModeLocate DownloadMode = iota DownloadModePCS DownloadModeStreaming )
type DownloadStatistic ¶
type DownloadStatistic struct {
pcsfunctions.Statistic
}
type DownloadTaskUnit ¶
type DownloadTaskUnit struct { Cfg *downloader.Config PCS *baidupcs.BaiduPCS ParentTaskExecutor *taskframework.TaskExecutor DownloadStatistic *DownloadStatistic // 下载统计 // 可选项 VerbosePrinter *pcsverbose.PCSVerbose PrintFormat string IsPrintStatus bool // 是否输出各个下载线程的详细信息 IsExecutedPermission bool // 下载成功后是否加上执行权限 IsOverwrite bool // 是否覆盖已存在的文件 NoCheck bool // 不校验文件 DlinkPrefer int // 使用所有备选下载链接中的第几个链接 ModifyMTime bool // 下载的文件mtime修改为与网盘一致 DownloadMode DownloadMode // 下载模式 PcsPath string // 要下载的网盘文件路径 SavePath string // 保存的路径 FileInfo *baidupcs.FileDirectory // 文件或目录详情 // contains filtered or unexported fields }
DownloadTaskUnit 下载的任务单元
func (*DownloadTaskUnit) OnComplete ¶
func (dtu *DownloadTaskUnit) OnComplete(lastRunResult *taskframework.TaskUnitRunResult)
func (*DownloadTaskUnit) OnFailed ¶
func (dtu *DownloadTaskUnit) OnFailed(lastRunResult *taskframework.TaskUnitRunResult)
func (*DownloadTaskUnit) OnRetry ¶
func (dtu *DownloadTaskUnit) OnRetry(lastRunResult *taskframework.TaskUnitRunResult)
func (*DownloadTaskUnit) OnSuccess ¶
func (dtu *DownloadTaskUnit) OnSuccess(lastRunResult *taskframework.TaskUnitRunResult)
func (*DownloadTaskUnit) RetryWait ¶
func (dtu *DownloadTaskUnit) RetryWait() time.Duration
func (*DownloadTaskUnit) Run ¶
func (dtu *DownloadTaskUnit) Run() (result *taskframework.TaskUnitRunResult)
func (*DownloadTaskUnit) SetTaskInfo ¶
func (dtu *DownloadTaskUnit) SetTaskInfo(info *taskframework.TaskInfo)
Click to show internal directories.
Click to hide internal directories.