fs

package
v4.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package fs provides filesystem operations for OpenList

Index

Constants

This section is empty.

Variables

View Source
var ArchiveContentUploadTaskManager = &archiveContentUploadTaskManagerType{
	Manager: nil,
}

ArchiveContentUploadTaskManager manages archive content upload tasks

View Source
var ArchiveDownloadTaskManager *tache.Manager[*ArchiveDownloadTask]

ArchiveDownloadTaskManager manages asynchronous archive download tasks

View Source
var CopyTaskManager *tache.Manager[*CopyTask]

CopyTaskManager manages asynchronous copy tasks

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

Functions

func ArchiveDecompress

func ArchiveDecompress(ctx context.Context, srcObjPath, dstDirPath string, args model.ArchiveDecompressArgs, lazyCache ...bool) (task.TaskExtensionInfo, error)

ArchiveDecompress 解压归档

func ArchiveDriverExtract

func ArchiveDriverExtract(ctx context.Context, path string, args model.ArchiveInnerArgs) (*model.Link, model.Obj, error)

ArchiveDriverExtract 提取归档内容

func ArchiveInternalExtract

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

ArchiveInternalExtract 内部提取归档内容

func ArchiveList

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

ArchiveList 列出归档内容

func ArchiveMeta

func ArchiveMeta(ctx context.Context, path string, args model.ArchiveMetaArgs) (*model.ArchiveMetaProvider, error)

ArchiveMeta 获取归档元数据

func Copy

func Copy(ctx context.Context, srcObjPath, dstDirPath string, lazyCache ...bool) (task.TaskExtensionInfo, error)

Copy 复制文件或目录

func Get

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

Get 获取指定路径的对象

func GetStorage

func GetStorage(path string, args *GetStoragesArgs) (driver.Driver, error)

GetStorage 获取存储驱动

func Link(ctx context.Context, path string, args model.LinkArgs) (*model.Link, model.Obj, error)

Link 获取指定路径对象的链接

func List

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

List 列出指定路径下的对象

func MakeDir

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

MakeDir 创建目录

func Move

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

Move 移动文件或目录

func MoveWithTask

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

MoveWithTask 创建移动任务

func MoveWithTaskAndValidation

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

MoveWithTaskAndValidation 创建带验证的移动任务

func Other

func Other(ctx context.Context, args model.FsOtherArgs) (any, error)

Other 执行其他文件系统操作

func PutAsTask

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

PutAsTask 创建上传任务

func PutDirectly

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

PutDirectly 直接上传文件

func PutURL

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

PutURL 从URL上传文件

func Remove

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

Remove 删除文件或目录

func Rename

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

Rename 重命名文件或目录

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 // Object name
	InPlace    bool   // Whether to upload in place or in a new directory
	FilePath   string // Path to the file or directory to upload
	DstDirPath string // Destination directory path

	DstStorageMp string // Destination storage mount path
	// contains filtered or unexported fields
}

ArchiveContentUploadTask represents a task for uploading decompressed archive content

func (*ArchiveContentUploadTask) Cancel

func (t *ArchiveContentUploadTask) Cancel()

Cancel cancels the task and cleans up resources if allowed

func (*ArchiveContentUploadTask) GetName

func (t *ArchiveContentUploadTask) GetName() string

GetName returns a human-readable name for the archive content upload task

func (*ArchiveContentUploadTask) GetStatus

func (t *ArchiveContentUploadTask) GetStatus() string

GetStatus returns the current status of the archive content upload task

func (*ArchiveContentUploadTask) Run

Run executes the archive content upload task

func (*ArchiveContentUploadTask) RunWithNextTaskCallback

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

RunWithNextTaskCallback executes the upload task with a custom callback for handling subtasks

type ArchiveDownloadTask

type ArchiveDownloadTask struct {
	task.TaskExtension
	model.ArchiveDecompressArgs

	SrcObjPath string // Source object path
	DstDirPath string // Destination directory path

	SrcStorageMp string // Source storage mount path
	DstStorageMp string // Destination storage mount path
	// contains filtered or unexported fields
}

ArchiveDownloadTask represents a task for downloading and decompressing archive files

func (*ArchiveDownloadTask) GetName

func (t *ArchiveDownloadTask) GetName() string

GetName returns a human-readable name for the archive download task

func (*ArchiveDownloadTask) GetStatus

func (t *ArchiveDownloadTask) GetStatus() string

GetStatus returns the current status of the archive download task

func (*ArchiveDownloadTask) Run

func (t *ArchiveDownloadTask) Run() error

Run executes the archive download task

func (*ArchiveDownloadTask) RunWithoutPushUploadTask

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

RunWithoutPushUploadTask performs the decompression without adding the resulting upload task to the manager Returns the upload task for the extracted content

type CopyTask

type CopyTask struct {
	task.TaskExtension
	Status       string `json:"-"`              // Current status (not persisted)
	SrcObjPath   string `json:"src_path"`       // Source object path
	DstDirPath   string `json:"dst_path"`       // Destination directory path
	SrcStorageMp string `json:"src_storage_mp"` // Source storage mount path
	DstStorageMp string `json:"dst_storage_mp"` // Destination storage mount path
	// contains filtered or unexported fields
}

CopyTask represents an asynchronous file/directory copy operation

func (*CopyTask) GetName

func (t *CopyTask) GetName() string

GetName returns a human-readable name for the copy task

func (*CopyTask) GetStatus

func (t *CopyTask) GetStatus() string

GetStatus returns the current status of the copy task

func (*CopyTask) Run

func (t *CopyTask) Run() error

Run executes the copy task It initializes the storage drivers if needed and delegates to copyBetween2Storages

type GetArgs

type GetArgs struct {
	NoLog bool
}

type GetStoragesArgs

type GetStoragesArgs struct {
}

type ListArgs

type ListArgs struct {
	Refresh bool
	NoLog   bool
}

type MoveProgress

type MoveProgress struct {
	TaskID         string `json:"task_id"`
	Phase          string `json:"phase"`
	TotalFiles     int    `json:"total_files"`
	CompletedFiles int    `json:"completed_files"`
	CurrentFile    string `json:"current_file"`
	Status         string `json:"status"`
	Progress       int    `json:"progress"`
}

func GetMoveProgress

func GetMoveProgress(taskID string) (*MoveProgress, bool)

GetMoveProgress returns the progress of a move task by task ID

func GetMoveTaskProgress

func GetMoveTaskProgress(task *MoveTask) *MoveProgress

GetMoveTaskProgress returns the progress of a specific move task

type MoveTask

type MoveTask struct {
	task.TaskExtension
	Status     string `json:"-"`
	SrcObjPath string `json:"src_path"`
	DstDirPath string `json:"dst_path"`

	SrcStorageMp      string `json:"src_storage_mp"`
	DstStorageMp      string `json:"dst_storage_mp"`
	IsRootTask        bool   `json:"is_root_task"`
	RootTaskID        string `json:"root_task_id"`
	TotalFiles        int    `json:"total_files"`
	CompletedFiles    int    `json:"completed_files"`
	Phase             string `json:"phase"` // "copying", "verifying", "deleting", "completed"
	ValidateExistence bool   `json:"validate_existence"`
	// contains filtered or unexported fields
}

func (*MoveTask) GetMoveProgress

func (t *MoveTask) GetMoveProgress() *MoveProgress

func (*MoveTask) GetName

func (t *MoveTask) GetName() string

func (*MoveTask) GetProgress

func (t *MoveTask) GetProgress() float64

func (*MoveTask) GetStatus

func (t *MoveTask) GetStatus() string

func (*MoveTask) Run

func (t *MoveTask) Run() error

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) Run

func (t *UploadTask) Run() error

Jump to

Keyboard shortcuts

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