local

package
v4.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addition

type Addition struct {
	driver.RootPath
	// Thumbnail 是否启用缩略图功能
	// 启用后,图片和视频文件将生成缩略图
	Thumbnail bool `json:"thumbnail" required:"true" help:"启用缩略图功能,支持图片和视频文件"`

	// ThumbCacheFolder 缩略图缓存文件夹路径
	// 如果为空,则不会缓存缩略图到磁盘,每次请求都会重新生成
	// 建议配置缓存目录以提高性能
	ThumbCacheFolder string `json:"thumb_cache_folder" help:"缩略图缓存文件夹路径,留空则不缓存缩略图,建议配置以提高性能"`

	// ThumbConcurrency 生成缩略图的并发数
	// 控制可以同时生成多少个缩略图,避免系统资源过度消耗
	// 设置为0表示无限制,但可能导致系统负载过高
	ThumbConcurrency string `` /* 150-byte string literal not displayed */

	// VideoThumbPos 视频缩略图位置
	// 如果是数字(整数或浮点数),表示视频的秒数
	// 如果以'%'结尾,表示视频时长的百分比
	// 例如:10表示第10秒,20%表示视频时长的20%位置
	VideoThumbPos string `` /* 157-byte string literal not displayed */

	// ShowHidden 是否显示隐藏文件和文件夹
	// 在Unix/Linux系统中,以点(.)开头的文件被视为隐藏文件
	// 在Windows系统中,通过文件属性的FILE_ATTRIBUTE_HIDDEN标志判断
	ShowHidden bool `json:"show_hidden" default:"false" required:"false" help:"是否显示隐藏的文件和文件夹,默认不显示"`

	// MkdirPerm 创建文件夹的权限,八进制表示
	// 仅在Unix/Linux系统中有效
	// 默认为777,表示所有用户都有读写执行权限
	MkdirPerm string `` /* 129-byte string literal not displayed */

	// RecycleBinPath 回收站路径
	// 如果为空或保持'delete permanently',则永久删除文件
	// 否则将删除的文件移动到指定的回收站目录
	RecycleBinPath string `` /* 164-byte string literal not displayed */
}

Addition 本地存储驱动的额外配置选项

type Local

type Local struct {
	model.Storage
	Addition
	// contains filtered or unexported fields
}

func (*Local) Config

func (d *Local) Config() driver.Config

func (*Local) Copy

func (d *Local) Copy(_ context.Context, srcObj, dstDir model.Obj) error

func (*Local) Drop

func (d *Local) Drop(ctx context.Context) error

func (*Local) FileInfoToObj

func (d *Local) FileInfoToObj(ctx context.Context, f fs.FileInfo, reqPath string, fullPath string) model.Obj

func (*Local) Get

func (d *Local) Get(ctx context.Context, path string) (model.Obj, error)

func (*Local) GetAddition

func (d *Local) GetAddition() driver.Additional

func (*Local) GetSnapshot

func (d *Local) GetSnapshot(videoPath string) (imgData *bytes.Buffer, err error)

Get the snapshot of the video

func (*Local) Init

func (d *Local) Init(ctx context.Context) error
func (d *Local) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error)

func (*Local) List

func (d *Local) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error)

func (*Local) MakeDir

func (d *Local) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error

func (*Local) Move

func (d *Local) Move(ctx context.Context, srcObj, dstDir model.Obj) error

func (*Local) Put

func (d *Local) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error

func (*Local) Remove

func (d *Local) Remove(ctx context.Context, obj model.Obj) error

func (*Local) Rename

func (d *Local) Rename(ctx context.Context, srcObj model.Obj, newName string) error

type NopTokenBucket

type NopTokenBucket struct {
	// contains filtered or unexported fields
}

NopTokenBucket 无操作令牌桶实现 所有操作都会立即成功,不进行实际限流

func NewNopTokenBucket

func NewNopTokenBucket() NopTokenBucket

NewNopTokenBucket 创建一个新的无操作令牌桶

func (NopTokenBucket) Do

func (b NopTokenBucket) Do(_ context.Context, f func() error) error

Do 直接执行函数,不进行限流

func (NopTokenBucket) Put

func (b NopTokenBucket) Put()

Put 无操作

func (NopTokenBucket) Take

func (b NopTokenBucket) Take() <-chan struct{}

Take 立即返回一个已关闭的通道

type StaticTokenBucket

type StaticTokenBucket struct {
	// contains filtered or unexported fields
}

StaticTokenBucket 固定大小的令牌桶实现 初始状态下桶是满的,令牌的获取和归还需要手动控制

func NewStaticTokenBucket

func NewStaticTokenBucket(size int) StaticTokenBucket

NewStaticTokenBucket 创建一个新的固定大小令牌桶 size: 桶的容量(最大令牌数)

func NewStaticTokenBucketWithMigration

func NewStaticTokenBucketWithMigration(oldBucket TokenBucket, size int) StaticTokenBucket

NewStaticTokenBucketWithMigration 创建一个新的令牌桶,并从旧桶迁移令牌 oldBucket: 旧的令牌桶 size: 新桶的容量

func (StaticTokenBucket) Do

func (b StaticTokenBucket) Do(ctx context.Context, f func() error) error

Do 使用令牌执行函数 ctx: 上下文,用于取消操作 f: 要执行的函数

func (StaticTokenBucket) Put

func (b StaticTokenBucket) Put()

Put 归还一个令牌到桶中

func (StaticTokenBucket) Take

func (b StaticTokenBucket) Take() <-chan struct{}

Take 获取一个令牌 注意:当驱动被修改时,通道可能会被关闭 通道关闭后不应再调用Put方法

type TokenBucket

type TokenBucket interface {
	// Take 获取一个令牌,返回一个通道,当有令牌可用时会收到信号
	Take() <-chan struct{}
	// Put 归还一个令牌到桶中
	Put()
	// Do 使用令牌执行函数,自动获取和归还令牌
	Do(context.Context, func() error) error
}

TokenBucket 令牌桶接口,用于限制并发操作

Jump to

Keyboard shortcuts

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