tool

package
v3.44.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

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) (task.TaskExtensionInfo, error)

Types

type AddURLArgs

type AddURLArgs struct {
	URL          string
	DstDirPath   string
	Tool         string
	DeletePolicy DeletePolicy
}

type AddUrlArgs

type AddUrlArgs struct {
	Url     string
	UID     string
	TempDir string
	Signal  chan int
}

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 {
	task.TaskExtension
	Url          string       `json:"url"`
	DstDirPath   string       `json:"dst_dir_path"`
	TempDir      string       `json:"temp_dir"`
	DeletePolicy DeletePolicy `json:"delete_policy"`
	Toolname     string       `json:"toolname"`
	Status       string       `json:"-"`
	Signal       chan int     `json:"-"`
	GID          string       `json:"-"`
	// contains filtered or unexported fields
}

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) Transfer added in v3.42.0

func (t *DownloadTask) Transfer() error

func (*DownloadTask) Update

func (t *DownloadTask) Update() (bool, error)

Update download status, return true if download completed

type Status

type Status struct {
	TotalBytes int64
	Progress   float64
	NewGID     string
	Completed  bool
	Status     string
	Err        error
}

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

type ToolsManager map[string]Tool

func (ToolsManager) Add

func (t ToolsManager) Add(tool Tool)

func (ToolsManager) Get

func (t ToolsManager) Get(name string) (Tool, error)

func (ToolsManager) Items

func (t ToolsManager) Items() []model.SettingItem

func (ToolsManager) Names

func (t ToolsManager) Names() []string

type TransferTask

type TransferTask struct {
	task.TaskExtension
	Status       string        `json:"-"` //don't save status to save space
	SrcObjPath   string        `json:"src_obj_path"`
	DstDirPath   string        `json:"dst_dir_path"`
	SrcStorage   driver.Driver `json:"-"`
	DstStorage   driver.Driver `json:"-"`
	SrcStorageMp string        `json:"src_storage_mp"`
	DstStorageMp string        `json:"dst_storage_mp"`
	DeletePolicy DeletePolicy  `json:"delete_policy"`
}

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

Jump to

Keyboard shortcuts

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