Documentation
¶
Overview ¶
Package fs provides filesystem operations for OpenList
Index ¶
- Variables
- 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 ClearCache()
- func Copy(ctx context.Context, srcObjPath, dstDirPath string, lazyCache ...bool) (task.TaskExtensionInfo, error)
- func Get(ctx context.Context, path string, args *GetArgs) (model.Obj, 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, lazyCache ...bool) error
- func Move(ctx context.Context, srcPath, dstDirPath string, lazyCache ...bool) error
- func MoveWithTask(ctx context.Context, srcPath, dstDirPath string, lazyCache ...bool) (task.TaskExtensionInfo, error)
- func MoveWithTaskAndValidation(ctx context.Context, srcPath, dstDirPath string, validateExistence bool, ...) (task.TaskExtensionInfo, error)
- func Other(ctx context.Context, args model.FsOtherArgs) (any, 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, lazyCache ...bool) error
- func SetConfig(config Config)
- 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) Run() error
- func (t *ArchiveContentUploadTask) RunWithNextTaskCallback(nextTaskCallback func(nextTask *ArchiveContentUploadTask) error) error
- type ArchiveDownloadTask
- type Config
- type CopyTask
- type GetArgs
- type GetStoragesArgs
- type ListArgs
- type MoveProgress
- type MoveTask
- type UploadTask
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCopyFailed 复制失败错误 ErrCopyFailed = errors.New("failed to copy file or directory") // ErrSourceNotFound 源对象未找到错误 ErrSourceNotFound = errors.New("source object not found") // ErrStreamCreationFailed 流创建失败错误 ErrStreamCreationFailed = errors.New("failed to create file stream") // ErrOperationCanceled 操作已取消错误 ErrOperationCanceled = errors.New("operation was canceled") )
自定义错误类型
var ( // ErrStorageNotFound 存储未找到错误 ErrStorageNotFound = errors.New("storage not found") // ErrListFailed 列表获取失败错误 ErrListFailed = errors.New("failed to get object list") )
自定义错误类型
var ( // ErrMakeDirFailed 创建目录失败错误 ErrMakeDirFailed = errors.New("failed to create directory") // ErrMoveFailed 移动失败错误 ErrMoveFailed = errors.New("failed to move object") // ErrRenameFailed 重命名失败错误 ErrRenameFailed = errors.New("failed to rename object") // ErrRemoveFailed 删除失败错误 ErrRemoveFailed = errors.New("failed to remove object") // ErrOtherOperationFailed 其他操作失败错误 ErrOtherOperationFailed = errors.New("operation failed") )
自定义错误类型
var ( // ErrUploadFailed 上传失败错误 ErrUploadFailed = errors.New("failed to upload file") // ErrTempFileFailed 临时文件创建失败错误 ErrTempFileFailed = errors.New("failed to create temporary file") )
自定义错误类型
var ( // ErrWalkFailed 遍历失败错误 ErrWalkFailed = errors.New("failed to walk filesystem") // ErrMaxDepthReached 已达到最大深度错误 ErrMaxDepthReached = errors.New("maximum walk depth reached") )
自定义错误类型
var ArchiveContentUploadTaskManager = &archiveContentUploadTaskManagerType{ Manager: nil, }
ArchiveContentUploadTaskManager manages archive content upload tasks
var ArchiveDownloadTaskManager *tache.Manager[*ArchiveDownloadTask]
ArchiveDownloadTaskManager manages asynchronous archive download tasks
var CopyTaskManager *tache.Manager[*CopyTask]
CopyTaskManager 管理异步复制任务
var DefaultConfig = Config{ DriverCacheTTL: 5 * time.Minute, ObjectCacheTTL: 30 * time.Second, EnableDriverCache: true, EnableObjectCache: true, }
DefaultConfig 默认配置
var ( // ErrLinkFailed 链接获取失败错误 ErrLinkFailed = errors.New("failed to get object link") )
自定义错误类型
var ( // ErrObjectNotFound 对象未找到错误 ErrObjectNotFound = errors.New("object not found") )
自定义错误类型
var MoveTaskManager *tache.Manager[*MoveTask]
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)
ArchiveDecompress 解压归档 参数:
- ctx: 上下文
- srcObjPath: 源对象路径
- dstDirPath: 目标目录路径
- args: 归档解压参数
- lazyCache: 是否延迟缓存
返回:
- task.TaskExtensionInfo: 任务信息
- error: 错误信息
func ArchiveDriverExtract ¶
func ArchiveDriverExtract(ctx context.Context, path string, args model.ArchiveInnerArgs) (*model.Link, model.Obj, error)
ArchiveDriverExtract 提取归档内容 参数:
- ctx: 上下文
- path: 路径
- args: 归档内部参数
返回:
- *model.Link: 链接信息
- model.Obj: 对象信息
- error: 错误信息
func ArchiveInternalExtract ¶
func ArchiveInternalExtract(ctx context.Context, path string, args model.ArchiveInnerArgs) (io.ReadCloser, int64, error)
ArchiveInternalExtract 内部提取归档内容 参数:
- ctx: 上下文
- path: 路径
- args: 归档内部参数
返回:
- io.ReadCloser: 读取器
- int64: 大小
- error: 错误信息
func ArchiveList ¶
ArchiveList 列出归档内容 参数:
- ctx: 上下文
- path: 路径
- args: 归档列表参数
返回:
- []model.Obj: 对象列表
- error: 错误信息
func ArchiveMeta ¶
func ArchiveMeta(ctx context.Context, path string, args model.ArchiveMetaArgs) (*model.ArchiveMetaProvider, error)
ArchiveMeta 获取归档元数据 参数:
- ctx: 上下文
- path: 路径
- args: 归档元数据参数
返回:
- *model.ArchiveMetaProvider: 归档元数据提供者
- error: 错误信息
func Copy ¶
func Copy(ctx context.Context, srcObjPath, dstDirPath string, lazyCache ...bool) (task.TaskExtensionInfo, error)
Copy 复制文件或目录 参数:
- ctx: 上下文
- srcObjPath: 源对象路径
- dstDirPath: 目标目录路径
- lazyCache: 是否延迟缓存
返回:
- task.TaskExtensionInfo: 任务信息
- error: 错误信息
func GetStorage ¶
func GetStorage(path string, args *GetStoragesArgs) (driver.Driver, error)
GetStorage 获取存储驱动 参数:
- path: 路径
- args: 获取存储参数
返回:
- driver.Driver: 存储驱动
- error: 错误信息
func Link ¶
Link 获取指定路径对象的链接 参数:
- ctx: 上下文
- path: 路径
- args: 链接参数
返回:
- *model.Link: 链接信息
- model.Obj: 对象信息
- error: 错误信息
func Move ¶
Move 移动文件或目录 参数:
- ctx: 上下文
- srcPath: 源路径
- dstDirPath: 目标目录路径
- lazyCache: 是否延迟缓存
返回:
- error: 错误信息
func MoveWithTask ¶
func MoveWithTask(ctx context.Context, srcPath, dstDirPath string, lazyCache ...bool) (task.TaskExtensionInfo, error)
MoveWithTask 创建移动任务 参数:
- ctx: 上下文
- srcPath: 源路径
- dstDirPath: 目标目录路径
- lazyCache: 是否延迟缓存
返回:
- task.TaskExtensionInfo: 任务信息
- error: 错误信息
func MoveWithTaskAndValidation ¶
func MoveWithTaskAndValidation(ctx context.Context, srcPath, dstDirPath string, validateExistence bool, lazyCache ...bool) (task.TaskExtensionInfo, error)
MoveWithTaskAndValidation 创建带验证的移动任务 参数:
- ctx: 上下文
- srcPath: 源路径
- dstDirPath: 目标目录路径
- validateExistence: 是否验证目标存在性
- lazyCache: 是否延迟缓存
返回:
- task.TaskExtensionInfo: 任务信息
- error: 错误信息
func PutAsTask ¶
func PutAsTask(ctx context.Context, dstDirPath string, file model.FileStreamer) (task.TaskExtensionInfo, error)
PutAsTask 创建上传任务 参数:
- ctx: 上下文
- dstDirPath: 目标目录路径
- file: 文件流
返回:
- task.TaskExtensionInfo: 任务信息
- error: 错误信息
func PutDirectly ¶
func PutDirectly(ctx context.Context, dstDirPath string, file model.FileStreamer, lazyCache ...bool) error
PutDirectly 直接上传文件 参数:
- ctx: 上下文
- dstDirPath: 目标目录路径
- file: 文件流
- lazyCache: 是否延迟缓存
返回:
- error: 错误信息
func Rename ¶
Rename 重命名文件或目录 参数:
- ctx: 上下文
- srcPath: 源路径
- dstName: 新名称
- lazyCache: 是否延迟缓存
返回:
- 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 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.
参数:
- ctx: 上下文
- depth: 最大遍历深度
- name: 起始路径
- info: 起始对象信息
- walkFn: 遍历回调函数
返回:
- error: 错误信息
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 ¶
func (t *ArchiveContentUploadTask) Run() error
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 Config ¶ added in v4.2.5
type Config struct {
// 驱动缓存TTL
DriverCacheTTL time.Duration
// 对象缓存TTL
ObjectCacheTTL time.Duration
// 是否启用驱动缓存
EnableDriverCache bool
// 是否启用对象缓存
EnableObjectCache bool
}
Config 配置选项
type CopyTask ¶
type CopyTask struct {
task.TaskExtension
Status string // 当前状态
SrcObjPath string // 源对象路径
DstDirPath string // 目标目录路径
SrcStorageMp string // 源存储挂载路径
DstStorageMp string // 目标存储挂载路径
// contains filtered or unexported fields
}
CopyTask 表示异步文件/目录复制操作
type GetStoragesArgs ¶
type GetStoragesArgs struct {
Refresh bool // 是否刷新缓存
}
GetStoragesArgs 获取存储参数结构体
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) GetProgress ¶
type UploadTask ¶
type UploadTask struct {
task.TaskExtension
// contains filtered or unexported fields
}
UploadTask 上传任务结构体