Documentation
¶
Index ¶
- Constants
- Variables
- func AddSeedGenerateTask(ctx context.Context, user *model.User, params SeedGenerateParams) (task.TaskExtensionInfo, error)
- func ArchiveDecompress(ctx context.Context, srcObjPath, dstDirPath string, ...) (task.TaskExtensionInfo, error)
- func ArchiveDriverExtract(ctx context.Context, path string, args model.ArchiveInnerArgs) (*model.Link, model.Obj, error)
- func ArchiveInternalExtract(ctx context.Context, path string, args model.ArchiveInnerArgs) (io.ReadCloser, int64, error)
- func ArchiveList(ctx context.Context, path string, args model.ArchiveListArgs) ([]model.Obj, error)
- func ArchiveMeta(ctx context.Context, path string, args model.ArchiveMetaArgs) (*model.ArchiveMetaProvider, error)
- func Copy(ctx context.Context, srcObjPath, dstDirPath string, skipHook ...bool) (task.TaskExtensionInfo, error)
- func CopyTo(ctx context.Context, srcObjPath, dstDirPath, dstName string, skipHook ...bool) (task.TaskExtensionInfo, error)
- func DeriveSeedName(paths []string) string
- func EncodeGeneratedSeed(seed *torrent.Seed, format string, standardPieces []byte) ([]byte, error)
- func Get(ctx context.Context, path string, args *GetArgs) (model.Obj, error)
- func GetDirectUploadInfo(ctx context.Context, tool, path, dstName string, fileSize int64, ...) (any, error)
- func GetStorage(path string, args *GetStoragesArgs) (driver.Driver, error)
- func Link(ctx context.Context, path string, args model.LinkArgs) (*model.Link, model.Obj, error)
- func List(ctx context.Context, path string, args *ListArgs) ([]model.Obj, error)
- func MakeDir(ctx context.Context, path string) error
- func Merge(ctx context.Context, srcObjPath, dstDirPath string, skipHook ...bool) (task.TaskExtensionInfo, error)
- func Move(ctx context.Context, srcPath, dstDirPath string, skipHook ...bool) (task.TaskExtensionInfo, error)
- func NormalizeSeedFormats(rawFormats []string) ([]string, error)
- func Other(ctx context.Context, args model.FsOtherArgs) (interface{}, error)
- func PutAsTask(ctx context.Context, dstDirPath string, file model.FileStreamer) (task.TaskExtensionInfo, error)
- func PutDirectly(ctx context.Context, dstDirPath string, file model.FileStreamer, ...) error
- func PutURL(ctx context.Context, path, dstName, urlStr string) error
- func Remove(ctx context.Context, path string) error
- func Rename(ctx context.Context, srcPath, dstName string, skipHook ...bool) error
- func SeedGenerateNeedsAsync(ctx context.Context, user *model.User, paths []string) (bool, error)
- func WalkFS(ctx context.Context, depth int, name string, info model.Obj, ...) error
- type ArchiveContentUploadTask
- func (t *ArchiveContentUploadTask) Cancel()
- func (t *ArchiveContentUploadTask) GetName() string
- func (t *ArchiveContentUploadTask) GetStatus() string
- func (t *ArchiveContentUploadTask) OnFailed()
- func (t *ArchiveContentUploadTask) OnSucceeded()
- func (t *ArchiveContentUploadTask) Run() error
- func (t *ArchiveContentUploadTask) RunWithNextTaskCallback(f func(nextTask *ArchiveContentUploadTask) error) error
- func (t *ArchiveContentUploadTask) SetRetry(retry int, maxRetry int)
- type ArchiveDownloadTask
- type FileTransferTask
- func (t *FileTransferTask) GetName() string
- func (t *FileTransferTask) OnFailed()
- func (t *FileTransferTask) OnSucceeded()
- func (t *FileTransferTask) Run() error
- func (t *FileTransferTask) RunWithNextTaskCallback(f func(nextTask *FileTransferTask) error) error
- func (t *FileTransferTask) SetRetry(retry int, maxRetry int)
- type GetArgs
- type GetStoragesArgs
- type ListArgs
- type SeedArtifact
- type SeedGenerateParams
- type SeedGenerateTask
- type SeedHashMatrix
- type SeedHashSelection
- type TaskData
- type UploadTask
Constants ¶
const MaxSeedGenerateSyncSize = 1 * 1024 * 1024 * 1024
MaxSeedGenerateSyncSize bounds synchronous seed generation (1GB). Larger requests are turned into an asynchronous task.
Variables ¶
var ( CopyTaskManager *tache.Manager[*FileTransferTask] MoveTaskManager *tache.Manager[*FileTransferTask] )
var ArchiveContentUploadTaskManager = &archiveContentUploadTaskManagerType{ Manager: nil, }
var ArchiveDownloadTaskManager *tache.Manager[*ArchiveDownloadTask]
var SeedGenerateTaskManager *tache.Manager[*SeedGenerateTask]
var UploadTaskManager *tache.Manager[*UploadTask]
Functions ¶
func AddSeedGenerateTask ¶ added in v4.2.8
func AddSeedGenerateTask(ctx context.Context, user *model.User, params SeedGenerateParams) (task.TaskExtensionInfo, error)
AddSeedGenerateTask schedules an asynchronous seed generation task.
func ArchiveDecompress ¶
func ArchiveDecompress(ctx context.Context, srcObjPath, dstDirPath string, args model.ArchiveDecompressArgs, lazyCache ...bool) (task.TaskExtensionInfo, error)
func ArchiveDriverExtract ¶
func ArchiveInternalExtract ¶
func ArchiveInternalExtract(ctx context.Context, path string, args model.ArchiveInnerArgs) (io.ReadCloser, int64, error)
func ArchiveList ¶
func ArchiveMeta ¶
func ArchiveMeta(ctx context.Context, path string, args model.ArchiveMetaArgs) (*model.ArchiveMetaProvider, error)
func CopyTo ¶ added in v4.2.8
func CopyTo(ctx context.Context, srcObjPath, dstDirPath, dstName string, skipHook ...bool) (task.TaskExtensionInfo, error)
CopyTo copies a file or directory to dstDirPath using dstName as its name.
func DeriveSeedName ¶ added in v4.2.8
DeriveSeedName derives a sensible default seed name from the source paths: single selection uses the file name, multi selection uses the common base name (ignoring extensions) when all files share one, otherwise the folder name.
func EncodeGeneratedSeed ¶ added in v4.2.8
EncodeGeneratedSeed serializes a seed in the requested container format.
func GetDirectUploadInfo ¶ added in v4.1.7
func GetStorage ¶
func GetStorage(path string, args *GetStoragesArgs) (driver.Driver, error)
func NormalizeSeedFormats ¶ added in v4.2.8
NormalizeSeedFormats validates and deduplicates a list of seed format names.
func PutAsTask ¶
func PutAsTask(ctx context.Context, dstDirPath string, file model.FileStreamer) (task.TaskExtensionInfo, error)
func PutDirectly ¶
func SeedGenerateNeedsAsync ¶ added in v4.2.8
SeedGenerateNeedsAsync reports whether the given files must be generated asynchronously because they exceed the synchronous size limit. It resolves each path and sums the file sizes, returning the first error encountered.
func WalkFS ¶
func WalkFS(ctx context.Context, depth int, name string, info model.Obj, walkFn func(reqPath string, info model.Obj) error) error
WalkFS traverses filesystem fs starting at name up to depth levels.
WalkFS will stop when current depth > `depth`. For each visited node, WalkFS calls walkFn. If a visited file system node is a directory and walkFn returns path.SkipDir, walkFS will skip traversal of this node.
Types ¶
type ArchiveContentUploadTask ¶
type ArchiveContentUploadTask struct {
task.TaskExtension
ObjName string
InPlace bool
FilePath string
DstActualPath string
DstStorageMp string
// contains filtered or unexported fields
}
func (*ArchiveContentUploadTask) Cancel ¶
func (t *ArchiveContentUploadTask) Cancel()
func (*ArchiveContentUploadTask) GetName ¶
func (t *ArchiveContentUploadTask) GetName() string
func (*ArchiveContentUploadTask) GetStatus ¶
func (t *ArchiveContentUploadTask) GetStatus() string
func (*ArchiveContentUploadTask) OnFailed ¶ added in v4.0.9
func (t *ArchiveContentUploadTask) OnFailed()
func (*ArchiveContentUploadTask) OnSucceeded ¶ added in v4.0.9
func (t *ArchiveContentUploadTask) OnSucceeded()
func (*ArchiveContentUploadTask) Run ¶
func (t *ArchiveContentUploadTask) Run() error
func (*ArchiveContentUploadTask) RunWithNextTaskCallback ¶
func (t *ArchiveContentUploadTask) RunWithNextTaskCallback(f func(nextTask *ArchiveContentUploadTask) error) error
func (*ArchiveContentUploadTask) SetRetry ¶ added in v4.0.9
func (t *ArchiveContentUploadTask) SetRetry(retry int, maxRetry int)
type ArchiveDownloadTask ¶
type ArchiveDownloadTask struct {
TaskData
model.ArchiveDecompressArgs
}
func (*ArchiveDownloadTask) GetName ¶
func (t *ArchiveDownloadTask) GetName() string
func (*ArchiveDownloadTask) Run ¶
func (t *ArchiveDownloadTask) Run() error
func (*ArchiveDownloadTask) RunWithoutPushUploadTask ¶
func (t *ArchiveDownloadTask) RunWithoutPushUploadTask() (*ArchiveContentUploadTask, error)
type FileTransferTask ¶ added in v4.0.9
type FileTransferTask struct {
TaskData
TaskType taskType
// contains filtered or unexported fields
}
func (*FileTransferTask) GetName ¶ added in v4.0.9
func (t *FileTransferTask) GetName() string
func (*FileTransferTask) OnFailed ¶ added in v4.0.9
func (t *FileTransferTask) OnFailed()
func (*FileTransferTask) OnSucceeded ¶ added in v4.0.9
func (t *FileTransferTask) OnSucceeded()
func (*FileTransferTask) Run ¶ added in v4.0.9
func (t *FileTransferTask) Run() error
func (*FileTransferTask) RunWithNextTaskCallback ¶ added in v4.1.0
func (t *FileTransferTask) RunWithNextTaskCallback(f func(nextTask *FileTransferTask) error) error
func (*FileTransferTask) SetRetry ¶ added in v4.0.9
func (t *FileTransferTask) SetRetry(retry int, maxRetry int)
type GetStoragesArgs ¶
type GetStoragesArgs struct {
}
type SeedArtifact ¶ added in v4.2.8
type SeedArtifact struct {
Format string `json:"format"`
Name string `json:"name"`
FileName string `json:"file_name"`
SeedData string `json:"seed_data"`
Size int `json:"size"`
Path string `json:"path,omitempty"`
}
SeedArtifact is one generated seed container.
func GenerateSeedArtifacts ¶ added in v4.2.8
func GenerateSeedArtifacts(ctx context.Context, user *model.User, params SeedGenerateParams) ([]SeedArtifact, *torrent.Seed, error)
GenerateSeedArtifacts reads each file once while computing the requested hashes, then emits one or more seed containers. It has no HTTP dependency and can be driven synchronously or from a background task.
type SeedGenerateParams ¶ added in v4.2.8
type SeedGenerateParams struct {
Paths []string
Formats []string
Name string
Comment string
FileComments map[string]string
HashMatrix SeedHashMatrix
PieceSize int64
Trackers []string
Channels []torrent.SeedChannel
OutputPath string
IncludeDirectSource bool
DirectFiles []string
}
SeedGenerateParams carries a fully-resolved seed generation request, free of any HTTP transport concerns so it can run synchronously or as a task.
type SeedGenerateTask ¶ added in v4.2.8
type SeedGenerateTask struct {
task.TaskExtension
// contains filtered or unexported fields
}
SeedGenerateTask generates seed containers asynchronously, writing them into params.OutputPath so they appear in the target folder once done.
func (*SeedGenerateTask) GetName ¶ added in v4.2.8
func (t *SeedGenerateTask) GetName() string
func (*SeedGenerateTask) GetStatus ¶ added in v4.2.8
func (t *SeedGenerateTask) GetStatus() string
func (*SeedGenerateTask) Run ¶ added in v4.2.8
func (t *SeedGenerateTask) Run() error
type SeedHashMatrix ¶ added in v4.2.8
type SeedHashMatrix struct {
MD5 SeedHashSelection `json:"md5"`
SHA1 SeedHashSelection `json:"sha1"`
SHA256 SeedHashSelection `json:"sha256"`
}
SeedHashMatrix controls the optional hash metadata stored in a seed.
type SeedHashSelection ¶ added in v4.2.8
SeedHashSelection controls whole-file and piece hash inclusion.
type TaskData ¶ added in v4.0.9
type TaskData struct {
task.TaskExtension
Status string `json:"-"` //don't save status to save space
SrcActualPath string `json:"src_path"`
DstActualPath string `json:"dst_path"`
DstName string `json:"dst_name,omitempty"`
SrcStorage driver.Driver `json:"-"`
DstStorage driver.Driver `json:"-"`
SrcStorageMp string `json:"src_storage_mp"`
DstStorageMp string `json:"dst_storage_mp"`
}
type UploadTask ¶
type UploadTask struct {
task.TaskExtension
// contains filtered or unexported fields
}
func (*UploadTask) GetName ¶
func (t *UploadTask) GetName() string
func (*UploadTask) GetStatus ¶
func (t *UploadTask) GetStatus() string
func (*UploadTask) OnFailed ¶ added in v4.0.9
func (t *UploadTask) OnFailed()
func (*UploadTask) OnSucceeded ¶ added in v4.0.9
func (t *UploadTask) OnSucceeded()
func (*UploadTask) Run ¶
func (t *UploadTask) Run() error
func (*UploadTask) SetRetry ¶ added in v4.0.9
func (t *UploadTask) SetRetry(retry int, maxRetry int)