Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
DownloadTaskManager *tache.Manager[*DownloadTask]
)
View Source
var (
Tools = make(ToolsManager)
)
View Source
var (
TransferTaskManager *tache.Manager[*TransferTask]
)
Functions ¶
func AddURL ¶
func AddURL(ctx context.Context, args *AddURLArgs) (tache.TaskWithInfo, error)
Types ¶
type AddURLArgs ¶
type AddURLArgs struct { URL string DstDirPath string Tool string DeletePolicy DeletePolicy }
type DeletePolicy ¶
type DeletePolicy string
const ( DeleteOnUploadSucceed DeletePolicy = "delete_on_upload_succeed" DeleteOnUploadFailed DeletePolicy = "delete_on_upload_failed" DeleteNever DeletePolicy = "delete_never" DeleteAlways DeletePolicy = "delete_always" )
type DownloadTask ¶
type DownloadTask struct { tache.Base Url string `json:"url"` DstDirPath string `json:"dst_dir_path"` TempDir string `json:"temp_dir"` DeletePolicy DeletePolicy `json:"delete_policy"` Status string `json:"status"` Signal chan int `json:"-"` GID string `json:"-"` // contains filtered or unexported fields }
func (*DownloadTask) Complete ¶
func (t *DownloadTask) Complete() error
func (*DownloadTask) GetName ¶
func (t *DownloadTask) GetName() string
func (*DownloadTask) GetStatus ¶
func (t *DownloadTask) GetStatus() string
func (*DownloadTask) Run ¶
func (t *DownloadTask) Run() error
func (*DownloadTask) Update ¶
func (t *DownloadTask) Update() (bool, error)
Update download status, return true if download completed
type File ¶
type File struct { // ReadCloser for http client ReadCloser io.ReadCloser Name string Size int64 Path string Modified time.Time }
func (*File) GetReadCloser ¶
func (f *File) GetReadCloser() (io.ReadCloser, error)
type GetFileser ¶
type GetFileser interface { // GetFiles return the files of the download task, if nil, means walk the temp dir to get the files GetFiles(task *DownloadTask) []File }
type Tool ¶
type Tool interface { Name() string // Items return the setting items the tool need Items() []model.SettingItem Init() (string, error) IsReady() bool // AddURL add an uri to download, return the task id AddURL(args *AddUrlArgs) (string, error) // Remove the download if task been canceled Remove(task *DownloadTask) error // Status return the status of the download task, if an error occurred, return the error in Status.Err Status(task *DownloadTask) (*Status, error) // Run for simple http download Run(task *DownloadTask) error }
type ToolsManager ¶
func (ToolsManager) Add ¶
func (t ToolsManager) Add(tool Tool)
func (ToolsManager) Items ¶
func (t ToolsManager) Items() []model.SettingItem
func (ToolsManager) Names ¶
func (t ToolsManager) Names() []string
type TransferTask ¶
func (*TransferTask) GetName ¶
func (t *TransferTask) GetName() string
func (*TransferTask) GetStatus ¶
func (t *TransferTask) GetStatus() string
func (*TransferTask) OnFailed ¶
func (t *TransferTask) OnFailed()
func (*TransferTask) OnSucceeded ¶
func (t *TransferTask) OnSucceeded()
func (*TransferTask) Run ¶
func (t *TransferTask) Run() error
Click to show internal directories.
Click to hide internal directories.