Documentation ¶
Overview ¶
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func CheckFileValid(filePath string, fileInfo *aliyunpan.FileEntity) error
- func FileExist(path string) bool
- func SymlinkFileExist(fullPath, rootPath string) bool
- type DownloadStatistic
- type DownloadTaskUnit
- func (dtu *DownloadTaskUnit) OnCancel(lastRunResult *taskframework.TaskUnitRunResult)
- 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)
- type FileSourceType
Constants ¶
const ( // DefaultPrintFormat 默认的下载进度输出格式 DefaultPrintFormat = "\r[%s] ↓ %s/%s %s/s in %s, left %s ............" //DownloadSuffix 文件下载后缀 DownloadSuffix = ".aliyunpan-downloading" //StrDownloadInitError 初始化下载发生错误 StrDownloadInitError = "初始化下载发生错误" // StrDownloadFailed 下载文件失败 StrDownloadFailed = "下载文件失败" // StrDownloadGetDlinkFailed 获取下载链接失败 StrDownloadGetDlinkFailed = "获取下载链接失败" // StrDownloadChecksumFailed 检测文件有效性失败 StrDownloadChecksumFailed = "检测文件有效性失败" // DefaultDownloadMaxRetry 默认下载失败最大重试次数 DefaultDownloadMaxRetry = 3 // BackupFileSource 备份盘文件 BackupFileSource FileSourceType = "backup" // ResourceFileSource 资源库文件 ResourceFileSource FileSourceType = "resource" // AlbumFileSource 相册文件 AlbumFileSource FileSourceType = "album" )
Variables ¶
var ( // ErrDownloadNotSupportChecksum 文件不支持校验 ErrDownloadNotSupportChecksum = errors.New("该文件不支持校验") // ErrDownloadChecksumFailed 文件校验失败 ErrDownloadChecksumFailed = errors.New("该文件校验失败, 文件md5值与服务器记录的不匹配") // ErrDownloadFileBanned 违规文件 ErrDownloadFileBanned = errors.New("该文件可能是违规文件, 不支持校验") // ErrDlinkNotFound 未取得下载链接 ErrDlinkNotFound = errors.New("未取得下载链接") ErrShareInfoNotFound = errors.New("未在已分享列表中找到分享信息") )
Functions ¶
func CheckFileValid ¶
func CheckFileValid(filePath string, fileInfo *aliyunpan.FileEntity) error
CheckFileValid 检测文件有效性
Types ¶
type DownloadStatistic ¶
type DownloadTaskUnit ¶
type DownloadTaskUnit struct { Cfg *downloader.Config PanClient *config.PanClient ParentTaskExecutor *taskframework.TaskExecutor DownloadStatistic *DownloadStatistic // 下载统计 GlobalSpeedsStat *speeds.Speeds // 全局速度统计 // 可选项 VerbosePrinter *logger.CmdVerbose PrintFormat string IsPrintStatus bool // 是否输出各个下载线程的详细信息 IsExecutedPermission bool // 下载成功后是否加上执行权限 IsOverwrite bool // 是否覆盖已存在的文件 NoCheck bool // 不校验文件 FilePanPath string // 要下载的网盘文件路径 SavePath string // 文件保存在本地的路径 OriginSaveRootPath string // 文件保存在本地的根目录路径 DriveId string // 下载文件记录器 FileRecorder *log.FileRecorder // contains filtered or unexported fields }
DownloadTaskUnit 下载的任务单元
func (*DownloadTaskUnit) OnCancel ¶ added in v0.1.4
func (dtu *DownloadTaskUnit) OnCancel(lastRunResult *taskframework.TaskUnitRunResult)
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)
type FileSourceType ¶ added in v0.2.8
type FileSourceType string