pandownload

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

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

View Source
const (
	// DefaultPrintFormat 默认的下载进度输出格式
	DefaultPrintFormat = "\r[%s] ↓ %s/%s %s/s in %s, left %s ............"
	//DownloadSuffix 文件下载后缀
	DownloadSuffix = ".cloudpan189-downloading"
	//StrDownloadInitError 初始化下载发生错误
	StrDownloadInitError = "初始化下载发生错误"
	// StrDownloadFailed 下载文件失败
	StrDownloadFailed = "下载文件失败"
	// StrDownloadGetDlinkFailed 获取下载链接失败
	StrDownloadGetDlinkFailed = "获取下载链接失败"
	// StrDownloadChecksumFailed 检测文件有效性失败
	StrDownloadChecksumFailed = "检测文件有效性失败"
	// 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 未在已分享列表中找到分享信息
	ErrShareInfoNotFound = errors.New("未在已分享列表中找到分享信息")
)

Functions

func CheckFileValid

func CheckFileValid(filePath string, fileInfo *cloudpan.AppFileEntity) error

CheckFileValid 检测文件有效性

func FileExist

func FileExist(path string) bool

FileExist 检查文件是否存在, 只有当文件存在, 文件大小不为0或断点续传文件不存在时, 才判断为存在

Types

type DownloadStatistic

type DownloadStatistic struct {
	functions.Statistic
}

type DownloadTaskUnit

type DownloadTaskUnit struct {
	Cfg                *downloader.Config
	PanClient          *cloudpan.PanClient
	ParentTaskExecutor *taskframework.TaskExecutor

	DownloadStatistic *DownloadStatistic // 下载统计

	// 可选项
	VerbosePrinter       *logger.CmdVerbose
	PrintFormat          string
	IsPrintStatus        bool // 是否输出各个下载线程的详细信息
	IsExecutedPermission bool // 下载成功后是否加上执行权限
	IsOverwrite          bool // 是否覆盖已存在的文件
	NoCheck              bool // 不校验文件

	FilePanPath        string // 要下载的网盘文件路径
	SavePath           string // 文件保存在本地的路径
	OriginSaveRootPath string // 文件保存在本地的根目录路径
	FamilyId           int64  // 家庭云ID, 个人云默认为0
	// 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)

Jump to

Keyboard shortcuts

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