fs

package
v4.2.8 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrArchiveMetaFailed       = errors.New("failed to get archive metadata")
	ErrArchiveListFailed       = errors.New("failed to list archive contents")
	ErrArchiveDecompressFailed = errors.New("failed to decompress archive")
	ErrArchiveExtractFailed    = errors.New("failed to extract from archive")
	ErrTempFileCreationFailed  = errors.New("failed to create temporary file")
)

自定义错误类型

View Source
var (
	ErrTransferFailed = errors.New("transfer failed")
	ErrCopyFailed     = errors.New("copy failed")
	ErrMoveFailed     = errors.New("move failed")
)

自定义错误类型

View Source
var (
	CopyTaskManager *tache.Manager[*FileTransferTask]
	MoveTaskManager *tache.Manager[*FileTransferTask]
)

任务管理器

View Source
var (
	// ErrObjectNotFound 对象未找到错误
	ErrObjectNotFound = errors.New("object not found")

	// ErrInvalidPath 无效路径错误
	ErrInvalidPath = errors.New("invalid path")
)

自定义错误类型

View Source
var (
	ErrMakeDirFailed = errors.New("failed to make directory")
	ErrRenameFailed  = errors.New("failed to rename object")
	ErrRemoveFailed  = errors.New("failed to remove object")
	ErrOtherFailed   = errors.New("operation failed")
)

自定义错误类型

View Source
var ArchiveContentUploadTaskManager = &archiveContentUploadTaskManagerType{
	Manager: nil,
}
View Source
var ArchiveDownloadTaskManager *tache.Manager[*ArchiveDownloadTask]

ArchiveDownloadTaskManager 归档下载任务管理器

View Source
var ErrLinkFailed = errors.New("failed to generate link")

ErrLinkFailed 链接生成失败错误

View Source
var ErrListFailed = errors.New("failed to list objects")

ErrListFailed 列表获取失败错误

View Source
var (
	ErrUploadFailed = errors.New("upload failed")
)

自定义错误类型

View Source
var ErrWalkFailed = errors.New("walk failed")

ErrWalkFailed 遍历失败错误

View Source
var UploadTaskManager *tache.Manager[*UploadTask]

UploadTaskManager 上传任务管理器

Functions

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

func Get

func Get(ctx context.Context, path string, args *GetArgs) (model.Obj, 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, lazyCache ...bool) error

func Move

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

func Other

func Other(ctx context.Context, args model.FsOtherArgs) (any, 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, lazyCache ...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, lazyCache ...bool) error

func WalkFS

func WalkFS(ctx context.Context, depth int, name string, info model.Obj, walkFn func(reqPath string, info model.Obj) error) error

WalkFS 遍历文件系统,从指定名称开始,最多遍历到指定深度

WalkFS 在当前深度 > `depth` 时停止。对于每个访问的节点, WalkFS 调用 walkFn。如果访问的文件系统节点是一个目录,并且 walkFn 返回 path.SkipDir,walkFS 将跳过该节点的遍历。

参数:

  • ctx: 上下文
  • depth: 最大遍历深度
  • name: 起始路径
  • info: 起始对象信息
  • walkFn: 遍历回调函数

返回:

  • error: 错误信息

Types

type ArchiveContentUploadTask

type ArchiveContentUploadTask struct {
	task.TaskExtension

	ObjName       string
	InPlace       bool
	FilePath      string
	DstActualPath string

	DstStorageMp string
	// contains filtered or unexported fields
}

ArchiveContentUploadTask 归档内容上传任务结构

func (*ArchiveContentUploadTask) Cancel

func (t *ArchiveContentUploadTask) Cancel()

Cancel 取消任务

func (*ArchiveContentUploadTask) GetName

func (t *ArchiveContentUploadTask) GetName() string

GetName 获取任务名称 返回:

  • string: 任务名称

func (*ArchiveContentUploadTask) GetStatus

func (t *ArchiveContentUploadTask) GetStatus() string

GetStatus 获取任务状态 返回:

  • string: 任务状态

func (*ArchiveContentUploadTask) OnFailed added in v4.2.7

func (t *ArchiveContentUploadTask) OnFailed()

OnFailed 任务失败回调

func (*ArchiveContentUploadTask) OnSucceeded added in v4.2.7

func (t *ArchiveContentUploadTask) OnSucceeded()

OnSucceeded 任务成功回调

func (*ArchiveContentUploadTask) Run

Run 执行任务 返回:

  • error: 错误信息

func (*ArchiveContentUploadTask) RunWithNextTaskCallback

func (t *ArchiveContentUploadTask) RunWithNextTaskCallback(f func(nextTask *ArchiveContentUploadTask) error) error

RunWithNextTaskCallback 执行下一个任务回调 参数:

  • f: 回调函数

返回:

  • error: 错误信息

func (*ArchiveContentUploadTask) SetRetry added in v4.2.7

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

SetRetry 设置重试次数 参数:

  • retry: 当前重试次数
  • maxRetry: 最大重试次数

type ArchiveDownloadTask

type ArchiveDownloadTask struct {
	TaskData
	model.ArchiveDecompressArgs
}

ArchiveDownloadTask 归档下载任务结构

func (*ArchiveDownloadTask) GetName

func (t *ArchiveDownloadTask) GetName() string

GetName 获取任务名称 返回:

  • string: 任务名称

func (*ArchiveDownloadTask) Run

func (t *ArchiveDownloadTask) Run() error

Run 执行任务 返回:

  • error: 错误信息

func (*ArchiveDownloadTask) RunWithoutPushUploadTask

func (t *ArchiveDownloadTask) RunWithoutPushUploadTask() (*ArchiveContentUploadTask, error)

RunWithoutPushUploadTask 执行任务但不添加上传任务 返回:

  • *ArchiveContentUploadTask: 上传任务
  • error: 错误信息

type FileTransferTask added in v4.2.7

type FileTransferTask struct {
	TaskData
	TaskType taskType
	// contains filtered or unexported fields
}

FileTransferTask 文件传输任务结构

func (*FileTransferTask) GetName added in v4.2.7

func (t *FileTransferTask) GetName() string

GetName 获取任务名称 返回:

  • string: 任务名称

func (*FileTransferTask) OnFailed added in v4.2.7

func (t *FileTransferTask) OnFailed()

OnFailed 任务失败回调

func (*FileTransferTask) OnSucceeded added in v4.2.7

func (t *FileTransferTask) OnSucceeded()

OnSucceeded 任务成功回调

func (*FileTransferTask) Run added in v4.2.7

func (t *FileTransferTask) Run() error

Run 执行任务 返回:

  • error: 错误信息

func (*FileTransferTask) SetRetry added in v4.2.7

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

SetRetry 设置重试 参数:

  • retry: 当前重试次数
  • maxRetry: 最大重试次数

type GetArgs

type GetArgs struct {
	NoLog bool
}

type GetStoragesArgs

type GetStoragesArgs struct {
	SkipCache bool
}

type ListArgs

type ListArgs struct {
	Refresh bool
	NoLog   bool
}

type TaskData added in v4.2.7

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"`
	SrcStorage    driver.Driver `json:"-"`
	DstStorage    driver.Driver `json:"-"`
	SrcStorageMp  string        `json:"src_storage_mp"`
	DstStorageMp  string        `json:"dst_storage_mp"`
}

TaskData 任务数据结构

func (*TaskData) GetStatus added in v4.2.7

func (t *TaskData) GetStatus() string

GetStatus 获取任务状态 返回:

  • string: 任务状态

type UploadTask

type UploadTask struct {
	task.TaskExtension
	// contains filtered or unexported fields
}

UploadTask 上传任务结构

func (*UploadTask) GetName

func (t *UploadTask) GetName() string

GetName 获取任务名称 返回:

  • string: 任务名称

func (*UploadTask) GetStatus

func (t *UploadTask) GetStatus() string

GetStatus 获取任务状态 返回:

  • string: 任务状态

func (*UploadTask) OnFailed added in v4.2.7

func (t *UploadTask) OnFailed()

OnFailed 任务失败回调

func (*UploadTask) OnSucceeded added in v4.2.7

func (t *UploadTask) OnSucceeded()

OnSucceeded 任务成功回调

func (*UploadTask) Run

func (t *UploadTask) Run() error

Run 执行任务 返回:

  • error: 错误信息

func (*UploadTask) SetRetry added in v4.2.7

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

SetRetry 设置重试 参数:

  • retry: 当前重试次数
  • maxRetry: 最大重试次数

Jump to

Keyboard shortcuts

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