tool

package
v4.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: AGPL-3.0 Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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)

func NativeToolName added in v4.2.7

func NativeToolName(storage driver.Driver) string

NativeToolName returns the offline-download tool implemented by storage.

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
	Ctx     context.Context
}

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"
	UploadDownloadStream  DeletePolicy = "upload_download_stream"
)

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

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

func (ToolsManager) NamesForPath added in v4.2.6

func (t ToolsManager) NamesForPath(path string) []string

NamesForPath returns ready tools and the native tool for the destination storage. Native tools can write directly to their own storage even without a temporary path setting.

type TransferTask

type TransferTask struct {
	fs.TaskData
	DeletePolicy DeletePolicy `json:"delete_policy"`
	Url          string       `json:"url"`
	// contains filtered or unexported fields
}

func (*TransferTask) GetName

func (t *TransferTask) GetName() string

func (*TransferTask) OnFailed

func (t *TransferTask) OnFailed()

func (*TransferTask) OnSucceeded

func (t *TransferTask) OnSucceeded()

func (*TransferTask) Run

func (t *TransferTask) Run() error

func (*TransferTask) SetRetry added in v4.0.9

func (t *TransferTask) SetRetry(retry int, maxRetry int)

Jump to

Keyboard shortcuts

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