feat: refactor task module
This commit is contained in:
@ -17,13 +17,14 @@ type AddUrlArgs struct {
|
||||
|
||||
type Status struct {
|
||||
Progress float64
|
||||
NewTID string
|
||||
NewGID string
|
||||
Completed bool
|
||||
Status string
|
||||
Err error
|
||||
}
|
||||
|
||||
type Tool interface {
|
||||
Name() string
|
||||
// Items return the setting items the tool need
|
||||
Items() []model.SettingItem
|
||||
Init() (string, error)
|
||||
@ -31,20 +32,23 @@ type Tool interface {
|
||||
// AddURL add an uri to download, return the task id
|
||||
AddURL(args *AddUrlArgs) (string, error)
|
||||
// Remove the download if task been canceled
|
||||
Remove(tid string) error
|
||||
Remove(task *DownloadTask) error
|
||||
// Status return the status of the download task, if an error occurred, return the error in Status.Err
|
||||
Status(tid string) (*Status, error)
|
||||
Status(task *DownloadTask) (*Status, error)
|
||||
}
|
||||
|
||||
type GetFileser interface {
|
||||
// GetFiles return the files of the download task, if nil, means walk the temp dir to get the files
|
||||
GetFiles(tid string) []File
|
||||
GetFiles(task *DownloadTask) []File
|
||||
}
|
||||
|
||||
type File struct {
|
||||
// ReadCloser for http client
|
||||
io.ReadCloser
|
||||
Name string
|
||||
Size int64
|
||||
Path string
|
||||
Modified time.Time
|
||||
ReadCloser io.ReadCloser
|
||||
Name string
|
||||
Size int64
|
||||
Path string
|
||||
Modified time.Time
|
||||
}
|
||||
|
||||
func (f *File) GetReadCloser() (io.ReadCloser, error) {
|
||||
|
Reference in New Issue
Block a user