fs

package
v4.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const MaxSeedGenerateSyncSize = 1 * 1024 * 1024 * 1024

MaxSeedGenerateSyncSize bounds synchronous seed generation (1GB). Larger requests are turned into an asynchronous task.

Variables

View Source
var (
	CopyTaskManager *tache.Manager[*FileTransferTask]
	MoveTaskManager *tache.Manager[*FileTransferTask]
)
View Source
var ArchiveContentUploadTaskManager = &archiveContentUploadTaskManagerType{
	Manager: nil,
}
View Source
var ArchiveDownloadTaskManager *tache.Manager[*ArchiveDownloadTask]
View Source
var SeedGenerateTaskManager *tache.Manager[*SeedGenerateTask]
View Source
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 ArchiveDriverExtract(ctx context.Context, path string, args model.ArchiveInnerArgs) (*model.Link, model.Obj, error)

func ArchiveInternalExtract

func ArchiveInternalExtract(ctx context.Context, path string, args model.ArchiveInnerArgs) (io.ReadCloser, int64, error)

func ArchiveList

func ArchiveList(ctx context.Context, path string, args model.ArchiveListArgs) ([]model.Obj, error)

func Copy

func Copy(ctx context.Context, srcObjPath, dstDirPath string, skipHook ...bool) (task.TaskExtensionInfo, 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

func DeriveSeedName(paths []string) string

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

func EncodeGeneratedSeed(seed *torrent.Seed, format string, standardPieces []byte) ([]byte, error)

EncodeGeneratedSeed serializes a seed in the requested container format.

func Get

func Get(ctx context.Context, path string, args *GetArgs) (model.Obj, error)

func GetDirectUploadInfo added in v4.1.7

func GetDirectUploadInfo(ctx context.Context, tool, path, dstName string, fileSize int64, overwrite bool) (any, error)

func GetStorage

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

func List(ctx context.Context, path string, args *ListArgs) ([]model.Obj, error)

func MakeDir

func MakeDir(ctx context.Context, path string) error

func Merge added in v4.1.8

func Merge(ctx context.Context, srcObjPath, dstDirPath string, skipHook ...bool) (task.TaskExtensionInfo, error)

func Move

func Move(ctx context.Context, srcPath, dstDirPath string, skipHook ...bool) (task.TaskExtensionInfo, error)

func NormalizeSeedFormats added in v4.2.8

func NormalizeSeedFormats(rawFormats []string) ([]string, error)

NormalizeSeedFormats validates and deduplicates a list of seed format names.

func Other

func Other(ctx context.Context, args model.FsOtherArgs) (interface{}, error)

func PutAsTask

func PutAsTask(ctx context.Context, dstDirPath string, file model.FileStreamer) (task.TaskExtensionInfo, error)

func PutDirectly

func PutDirectly(ctx context.Context, dstDirPath string, file model.FileStreamer, skipHook ...bool) error

func PutURL

func PutURL(ctx context.Context, path, dstName, urlStr string) error

func Remove

func Remove(ctx context.Context, path string) error

func Rename

func Rename(ctx context.Context, srcPath, dstName string, skipHook ...bool) error

func SeedGenerateNeedsAsync added in v4.2.8

func SeedGenerateNeedsAsync(ctx context.Context, user *model.User, paths []string) (bool, error)

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 (*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 GetArgs

type GetArgs struct {
	NoLog              bool
	WithStorageDetails bool
}

type GetStoragesArgs

type GetStoragesArgs struct {
}

type ListArgs

type ListArgs struct {
	Refresh            bool
	NoLog              bool
	WithStorageDetails bool
}

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
	IncludeShare        bool
	IncludeDirectSource bool
	ShareFiles          []string
	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

type SeedHashSelection struct {
	Whole  bool `json:"whole"`
	Pieces bool `json:"pieces"`
}

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"`
}

func (*TaskData) GetStatus added in v4.0.9

func (t *TaskData) GetStatus() string

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)

Jump to

Keyboard shortcuts

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